This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes IDEs, Version Control and other tools and the fly likes Is there succint Eclipse setup HOWTO for compiling java? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Is there succint Eclipse setup HOWTO for compiling java?" Watch "Is there succint Eclipse setup HOWTO for compiling java?" New topic
Author

Is there succint Eclipse setup HOWTO for compiling java?

Matt Kidd
Ranch Hand

Joined: Jul 17, 2002
Posts: 261
I've been searching the net and I can't seem to find any directions so I can set up eclipse to compile java. It seems I have to do 4 things every time I want to compile when I should just be able to click the run button.

Any help?
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10491
    
    9

Have you checked out http://eclipsetutorial.sourceforge.net/totalbeginner.html


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Matt Kidd
Ranch Hand

Joined: Jul 17, 2002
Posts: 261
Maneesh Godbole wrote:Have you checked out http://eclipsetutorial.sourceforge.net/totalbeginner.html


no but that doesn't appear to be very succint. I'll see if chapter 16 covers what I need.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

What specific problem(s) are you having? Eclipse compiles Java out-of-the-box.
Matt Kidd
Ranch Hand

Joined: Jul 17, 2002
Posts: 261
David Newton wrote:What specific problem(s) are you having? Eclipse compiles Java out-of-the-box.


My files weren't inside a specific project. Once I created a project (which I find annoying) Eclipse started taking care of itself.

Why must files be included/inside of a project to be compiled?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Because that is the nature of Eclipse.
Matt Kidd
Ranch Hand

Joined: Jul 17, 2002
Posts: 261
Now I'm having to change the configuration every time I compile the java source I'm looking at and currently editing. This makes sense since the project needs to know which main to use but is there a way to set it up to compile the source file I'm looking at? Or will I need to create a new configuration for each class that has a main?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

You're going to have to be more specific; normally a project would only have a single main.

If you have a project with many main methods, create new configs rather than changing the existing one.
Matt Kidd
Ranch Hand

Joined: Jul 17, 2002
Posts: 261
David Newton wrote:You're going to have to be more specific; normally a project would only have a single main.

If you have a project with many main methods, create new configs rather than changing the existing one.


*sigh*

okay. To be specific, the reason I have so many main methods is because I'm working through a book learning a new api and coding the examples. It's tedious but if this is the only way so be it.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16160
    
  21

Matt Kidd wrote:
David Newton wrote:You're going to have to be more specific; normally a project would only have a single main.

If you have a project with many main methods, create new configs rather than changing the existing one.


*sigh*

okay. To be specific, the reason I have so many main methods is because I'm working through a book learning a new api and coding the examples. It's tedious but if this is the only way so be it.


Actually, it's not that uncommon for a project to have multiple main methods. I know a number of people who set up projects with test code and it's run by running the class under test as a main class. Although JUnit is what I recommend - it allows better management of tests and provides a better supporting framework.

Eclipse is based on the concept of a Project. A Project doesn't have to be a directory inside an Eclipse workspace, but that's a convenient (and default) place to put them. Technically, the Project is a set of project definition files + workspace metadata, but we usually consider the directory containing the actual code and supporting files to be the "real" project. In order to keep things manageable, each Eclipse project must have a single root directory, although projects may "borrow" resources from other projects.

When an Eclipse project has been defined as a Java project, one or more directories are designated as Java Source Code directories, and one or more directories as compiled class directories. This can be adjusting using the Project Properties editor. Whenever you save changes to a Java Source Code file, it's automatically recompiled (unless you switch off that option) and the resulting class file gets placed under that source file's corresponding output class directory.

Running apps and debug sessions is actually done in a separate subsystem. You define a Run profile and specify not only the Main class, but any other environmental options you might need, such as classpath extensions, command-line options and so forth. It's really just the GUI equivalent of setting up batch execution files. You can set up as many different run profiles as you want (the same profiles can be used for both run and debug). It's also permissible to set up more than one profile for a given class. For example, if you want to test using a different set of run command-line options.

Run profiles also apply to other environments besides stand-alone Java applications, but the details vary, based on the environment. For example, the Applet run profiles invoke an Applet Runner.


Customer surveys are for companies who didn't pay proper attention to begin with.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5838
    
    7

the reason I have so many main methods is because I'm working through a book learning a new api and coding the examples.

Try this. Create a single empty Java project. Then when you need to create a new class for the next example, use Eclipse to create the class within that project. You can run the example either from a command line or within Eclipse by right-clicking the class and selecting Run As | Java Application.


JBoss In Action
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is there succint Eclipse setup HOWTO for compiling java?