This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes IDEs, Version Control and other tools and the fly likes Setting up Eclipse Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Setting up Eclipse" Watch "Setting up Eclipse" New topic
Author

Setting up Eclipse

Matthew Jamison
Greenhorn

Joined: Jan 04, 2007
Posts: 1
I have recently downloaded Eclipse SDK version 3.2.1. I created the
infamous program HelloWorld. I can run this program in the command
prompt, but for some reason i can't run the program in Eclipse. I get
the following error messages

(in the Java Virtual Machine Launcher window) Could not find the main
class. Program will exit.
(in the console) java.lang.NoClassDefFoundError: HelloWorld
(in the console) Exception in thread "main"

I have included the jdk in the PATH and classpath. I am not sure if that was needed, but i'm not sure what else to do.
Any help on this issue would be greatly appreciated.
Thanks
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Welcome to JavaRanch!

I'm moving this to our IDE forum for specialized attention. (See links at top of page to continue discussion there.)


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30580
    
154

Matthew,
Welcome to JavaRanch!

Check Window --> Preferences to make sure Eclipse is still pointing to a valid version of Java.

Also, note that Eclipse does not use the PATH and CLASSPATH specified on the operating system. Instead it uses a build path on the Eclipse project.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
David Seger
Greenhorn

Joined: Jan 10, 2007
Posts: 3
Originally posted by Matthew Jamison:
I have recently downloaded Eclipse SDK version 3.2.1. I created the
infamous program HelloWorld. I can run this program in the command
prompt, but for some reason i can't run the program in Eclipse. I get
the following error messages

(in the Java Virtual Machine Launcher window) Could not find the main
class. Program will exit.
(in the console) java.lang.NoClassDefFoundError: HelloWorld
(in the console) Exception in thread "main"

I have included the jdk in the PATH and classpath. I am not sure if that was needed, but i'm not sure what else to do.
Any help on this issue would be greatly appreciated.
Thanks
David Seger
Greenhorn

Joined: Jan 10, 2007
Posts: 3
Originally posted by Matthew Jamison:
I have recently downloaded Eclipse SDK version 3.2.1. I created the
infamous program HelloWorld. I can run this program in the command
prompt, but for some reason i can't run the program in Eclipse. I get
the following error messages

(in the Java Virtual Machine Launcher window) Could not find the main
class. Program will exit.
(in the console) java.lang.NoClassDefFoundError: HelloWorld
(in the console) Exception in thread "main"

I have included the jdk in the PATH and classpath. I am not sure if that was needed, but i'm not sure what else to do.
Any help on this issue would be greatly appreciated.
Thanks



Hi Matthew,

I've just installed Eclipse too and had exactly the same problem. Running a simple java application outside Eclipse was possible but not from Eclipse. In the "Run" meny, I changed "execution environment" from SDK to JRE and suddenly it was possible to run the Java program from inside Eclipse. I'm new to Java and have no possible explanation for the behaviour. /David
Caroline Jamison
Greenhorn

Joined: Jan 04, 2007
Posts: 3
I am new with this forum and didn't exactly know how things worked, so i started a new topic instead of adding it to this one. If you have any answers to Matt's question, please help me (his younger sister) and read the question I posted in More on Setting up Eclipse. Thanks!
Caroline Jamison
Greenhorn

Joined: Jan 04, 2007
Posts: 3
Hi David,
I don't really know where I have to change the execution environment. Could you please explain the steps on how to get there? Then maybe I will be able to change it, but I tried looking in the "Run" menu and didn't really know where to look. Thanks!
~Caroline
David Seger
Greenhorn

Joined: Jan 10, 2007
Posts: 3
Select Run -> Run from the meny list and a new window frame is viewed (Create, manage, and run configurations). Enter the name of your application/main class if not already filled in automatically. Press "JRE" meny (Main, (x)=Argument, JRE, Classpath......)

When selected, below "Runtime JRE:", your Project JRE is probably selected. I selected "Execution Environment" instead and tried some of the possible choices from the scroll bar. With some of them, I got the error message indicating that the main class couldn't be found when I pressed the Run button but when I selected JRE-1.1 or J2SE-1.5 everything seems to work!

When the execution environment has been changed according to the above steps you do not need to repeat the steps everytime you want to run your application. For now on you could use the Run button directly.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30580
    
154

Copied from other thread (which is now closed)
Jeanne, do you know what I would point it to in order for it to be a valid version of Java


Java is installed somewhere on the machine. You can check the operating system's PATH to find the exact location. (On Windows, this is an advanced property on "system" in the control panel. Alternatively, you can look in c:\java or c:\program files\java for a likely location.
Mr. C Lamont Gilbert
Ranch Hand

Joined: Oct 05, 2001
Posts: 1170

You should not have to be concerned about the execution environment. As I said in the other thread, you should be on the command line for now, and not using eclipse at all. Only start with Eclipse once you understand how Java works with the compiler and running the program and the classpath.

I use eclipse, but its going to add a whole host of other things for you to learn, and you are not going to know if what you are learning is Java related or Eclipse related. Just download the SDK and run everyting from the command prompt and use your favorite text editor. The programs you create now should be so small that it should not be an issue.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Setting up Eclipse