• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Is there succint Eclipse setup HOWTO for compiling java?

 
Ranch Hand
Posts: 267
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you checked out http://eclipsetutorial.sourceforge.net/totalbeginner.html
 
Matt Kidd
Ranch Hand
Posts: 267
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What specific problem(s) are you having? Eclipse compiles Java out-of-the-box.
 
Matt Kidd
Ranch Hand
Posts: 267
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Because that is the nature of Eclipse.
 
Matt Kidd
Ranch Hand
Posts: 267
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 267
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Saloon Keeper
Posts: 28313
207
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Normally trees don't drive trucks. Does this tiny ad have a license?
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic