Results 1 to 8 of 8
  1. #1
    tweaked88 is offline Member
    Join Date
    Feb 2013
    Posts
    5
    Rep Power
    0

    Default Confused - Trying to Run .java file in Eclipse

    New to this IDE. I created a simple class and method in Eclipse. When I click on the file, Eclipse launches, and then brings up my source code. When I go to click run, I have two "Ant Build" options, but no matter which one I choose, an error comes up saying "unable to find ant file to run."

    What is the process for compiling and running console programs?

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,839
    Rep Power
    8

    Default Re: Confused - Trying to Run .java file in Eclipse

    How are you running this? Do you have a Java project set up? You should be able to click the run dropdown, then click run as, then click application.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,755
    Rep Power
    19

    Default Re: Confused - Trying to Run .java file in Eclipse

    Right click on the actual class you want to run and select Run As-> Java Application.
    This tells Eclipse what your main class is.
    It should then appear as an option in the run button drop down.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  4. #4
    tweaked88 is offline Member
    Join Date
    Feb 2013
    Posts
    5
    Rep Power
    0

    Default Re: Confused - Trying to Run .java file in Eclipse

    Quote Originally Posted by KevinWorkman View Post
    How are you running this? Do you have a Java project set up? You should be able to click the run dropdown, then click run as, then click application.
    I just have a .java file with my source code. When I go to Run>Run As there are no options available.

  5. #5
    tweaked88 is offline Member
    Join Date
    Feb 2013
    Posts
    5
    Rep Power
    0

    Default Re: Confused - Trying to Run .java file in Eclipse

    Confused - Trying to Run .java file in Eclipse-screen-shot-2013-02-14-12.55.03-pm.pngHere is what I'm looking at...

  6. #6
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,839
    Rep Power
    8

    Default Re: Confused - Trying to Run .java file in Eclipse

    I'm pretty sure you need to create a project before you can run a file.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  7. #7
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,755
    Rep Power
    19

    Default Re: Confused - Trying to Run .java file in Eclipse

    Yep.
    Eclipse needs a project so it knows where to compile stuff to etc etc.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  8. #8
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    United States
    Posts
    3,340
    Rep Power
    5

    Default Re: Confused - Trying to Run .java file in Eclipse

    Yes. I have been using Eclipse for years. Just create a project. A simple skeletal Java file will be created for you. Just edit it as needed. Every time you save the file, the file will be compiled automatically. Then just left click the green arrow on the menu bar to run the program. Only in special situations do you need an ant file. I have hundreds of projects and only one ant file.

    Recommend you check out the Eclipse tutorials under the getting started section.

    Good luck!
    Jim

Similar Threads

  1. Eclipse / JPA and SaxParser - confused
    By alexandra12 in forum Eclipse
    Replies: 0
    Last Post: 08-05-2012, 02:10 AM
  2. Replies: 0
    Last Post: 09-09-2011, 11:04 AM
  3. Confused about File Input and Output Assignment
    By rugger06 in forum New To Java
    Replies: 2
    Last Post: 04-17-2011, 02:10 AM
  4. Using a text file in Eclipse...I'm confused
    By raindog308 in forum Eclipse
    Replies: 1
    Last Post: 01-18-2011, 02:34 AM
  5. Error while executing java file in eclipse
    By kutty in forum New To Java
    Replies: 0
    Last Post: 10-20-2010, 01:14 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •