Results 1 to 3 of 3
Thread: Can't compile with Eclipse
- 03-27-2012, 10:21 PM #1
Member
- Join Date
- Mar 2012
- Posts
- 5
- Rep Power
- 0
Can't compile with Eclipse
I've been doing some Java projects at school using Eclipse and i've got some homework to do during spring break.
I've downloaded Eclipse and all the needed Java plugins.
Now when I open a Java project that I worked on at school, it shows me the code, but when I click on "run as" it gives two options, both are "ants" or whatever. Doesn't matter which one i choose it won't show me the output, the actual program... Why ?
Any help ?
For example, this code worked perfectly fine at school, but won't do anything at home:
import java.util.Scanner;
class Car
{
Scanner scan = new Scanner(System.in);
double milesStart;
double milesEnd;
double gallons;
Car(double start, double end, double gals)
{
System.out.println("Enter starting miles: ");
start = scan.nextDouble();
milesStart = start;
System.out.println("Enter ending miles: ");
end = scan.nextDouble();
milesEnd = end;
System.out.println("Enter gallons used: ");
gals = scan.nextDouble();
gallons = gals;
}
double calculateMPG()
{
return (milesEnd - milesStart)/gallons;
}
boolean gasHog()
{
}
boolean economyCar()
{
}
}
class MPGTester
{
public static void main (String[] args)
{
Car car = new Car(0.0, 0.0, 0.0);
System.out.println( "MPG: " + car.calculateMPG() );
}
}
- 03-27-2012, 10:36 PM #2
Re: Can't compile with Eclipse
Post moved to the IDE's thread.
If you don't understand my response, don't ignore it, ask a question.
- 03-28-2012, 09:32 AM #3
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
Re: Can't compile with Eclipse
Right click on the java file containing the main() method, then choose RunAs...
This tells Eclipse what class you want to run (a project may contain many classes with a main(), or many different ways of running as well).
This is then added to your list of Run Configurations, which are accessible from the Run buttons (the green ones in the tool bar) should you not wish to always hunt around for the correct class to run.Please do not ask for code as refusal often offends.
Similar Threads
-
Java code / eclipse API's to close all open editors in eclipse
By userj2ee in forum EclipseReplies: 0Last Post: 07-27-2011, 12:52 PM -
Programs compile differently on 32-bit and 64-bit versions of eclipse?
By BAPandora in forum EclipseReplies: 1Last Post: 04-27-2011, 10:08 AM -
Trying to compile an eclipse RCP program
By mattlindsay in forum EclipseReplies: 0Last Post: 04-14-2011, 10:40 PM -
Eclipse Compile Error: Call validateValue(Class<T>, String, Object, Class<?>...)
By Tomshi in forum EclipseReplies: 0Last Post: 03-27-2011, 05:49 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks