|Re: Eclipse will only run first program HelloWorld [message #1692306 is a reply to message #1692290]
||Tue, 14 April 2015 23:32
| David Wegener
Registered: July 2009
In order to run an application, Eclipse creates a Launch Configuration |
that specifies things like the class to run, the classpath to run
against, the working directory to run in, etc.
Eclipse will remember the last application that you ran and will run
that as the default when you click the Run icon. This may be what you
are experiencing. In order to run your second application you need to
get a Launch Config created for it.
There are a couple of ways to do this. First, make sure that the
program you are trying to run is a valid Java application. The class
you want to run has to have a public static void main(String args) method.
If you have the class open in the Eclipse Java Editor, you can right
click in the editor window and select Run As->Java Application. This
will create a Launch Config using the class as the main class and
default the other items. It will then run the application.
You can do something similar from the Package Explorer view. Select
your main class, right click and again select Run As->Java Application.
A third way to create the Launch Config is to open the Run
Configurations dialog. From the menu select Run->Run Configurations...
Look for Java Application in the list on the left and follow the
Eclipse will keep track of the most recent programs you have run. If
you don't want to re-run the last one, you can click the down icon next
to the Run icon and get a list of previous programs to chose from.
Note that these options will only work if the program you wish to run is
in a Java Project. You select the type of project when you initially
create it from the New->Project menu. To check and see if you have a
Java project, right click on the project in Package Explorer and select
Properties. Java projects will have entries for Java Build Path, Java
Compiler, etc. If you don't see these in the properties dialog, you
need to create a Java project.
The Java Development Users Guide included in the Help has a Basic
Tutorial that goes over this in more detail. Look for the Running your
Finally, there is no Compile button. Eclipse has an incremental
compiler that is used to keep all of your code up to date each time you
save a file. The default setting has the incremental compiler turned
on. If you want to control builds, you have to turn off Project->Build
Automatically from the menu. With Build Automatically turned off, the
Project->Build All and Project->Build Project items are enabled and you
have to select them to perform builds.
Powered by FUDForum
. Page generated in 0.02343 seconds