Results 1 to 7 of 7
- 12-10-2008, 09:17 PM #1
Member
- Join Date
- Jun 2008
- Posts
- 85
- Rep Power
- 0
Using Eclipse IDE:java.lang.NoClassDefFoundError: main
Hi
The above code works fine when i compile and run it in command line window.Java Code:package Try; import java.io.File; public class Try { public static void main(String args[]) { String tmp=System.getProperty("user.dir"); System.out.println(tmp); } }
When I run the same code in Eclipse IDE 3.4.1.
"Could not find the main class.The program will exit" and in the console of the IDE I get this
So I went throu previous threads.Try to set the class path in two places.One in the properties window of the package and other was in the run configuration.Java Code:java.lang.NoClassDefFoundError: main Exception in thread "main"
I even tried the clean option as suggested in blogs,so that i could build the .class file,newly.
But nothing is working i get the same error..
Any suggestions ? or am i missing something..
Need help immediately
- 12-11-2008, 02:09 PM #2
Member
- Join Date
- Jun 2008
- Posts
- 85
- Rep Power
- 0
the problem which i am working on needs to have java 1.5 compliance.But eclipse compiler had java 1.6 compilance,so i had to change the jre from default 1.6 to 1.5,so does that have anything to do with my problem????
i am not able to proceed...i am just stuck up with this..any help plz?????
- 12-11-2008, 04:58 PM #3
Senior Member
- Join Date
- Sep 2008
- Posts
- 564
- Rep Power
- 5
in what directory are you running the program, and what does your directory structure look like? did you develop this code and directories using eclipse or just a text editor?
- 12-11-2008, 08:34 PM #4
Member
- Join Date
- Jun 2008
- Posts
- 85
- Rep Power
- 0
eclipse workspace is the directory in which i am running the program..directory structure look like? its in C:\Documents and Settings\Administrator\workspace\Try\Try
i just copy pasted the code from a tutorial,but made changes in eclipse...changes like the package name,the class name...
- 12-11-2008, 09:54 PM #5
Member
- Join Date
- Dec 2008
- Posts
- 30
- Rep Power
- 0
Try this.
Inside of eclipse, create a new project. Name it whatever
Right click that project and add a new class.
Paste this inside the class and it should work:
Your code was right, but I think making changes to the package name and class name after the fact created some issues.Java Code:public static void main(String args[]){ String tmp=System.getProperty("user.dir"); System.out.println(tmp); }
- 12-12-2008, 06:03 PM #6
Member
- Join Date
- Jun 2008
- Posts
- 85
- Rep Power
- 0
Hi
I just did exactly what you said..created new Java project,with new package and class name,pasted the above code..its just the same..main class not found,program will exit...
I thought of learning and working with eclipse IDE,I am just wasting time on it..the program works just fine with command line window..i wonder how ppl use IDE???
anyway,still i am open to suggestion or help...
- 12-12-2008, 10:17 PM #7
Member
- Join Date
- Dec 2008
- Posts
- 30
- Rep Power
- 0
An IDE is a wonderful thing. Once you get used to working with it you will wonder how you ever developed without it.
It may not seem like it while your learning how to use it, and writing small applications, but when you are writing enterprise software, and dealing with 50 classes and thousands of lines of code... it's nice.
Try right clicking on the errors (before trying to run them) and selecting 'Quick Fix' from the options.
Similar Threads
-
Exception in thread "main" java.lang.NoClassDefFoundError
By bhupal4all in forum New To JavaReplies: 12Last Post: 06-06-2012, 09:04 AM -
java.lang.NoClassDefFoundError in Eclipse at runtime
By debu37 in forum New To JavaReplies: 5Last Post: 09-03-2008, 05:29 PM -
Exception in thread "main" java.lang.NoClassDefFoundError: client Help
By b000m in forum New To JavaReplies: 6Last Post: 08-18-2008, 06:44 AM -
Exception in thread "main" java.lang.NoClassDefFoundError
By baltimore in forum New To JavaReplies: 1Last Post: 08-06-2007, 06:07 AM -
Exception in thread "main" java.lang.NoClassDefFoundError
By carl in forum New To JavaReplies: 2Last Post: 08-01-2007, 05:26 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks