File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Setting up Eclipse

 
Matthew Jamison
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch!

I'm moving this to our IDE forum for specialized attention. (See links at top of page to continue discussion there.)
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33685
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
David Seger
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 33685
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1170
Eclipse IDE Hibernate Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic