• Post Reply Bookmark Topic Watch Topic
  • New Topic

java.lang.NoClassDefFoundError: jdk1/5/0_04  RSS feed

 
Ganesan Ramakrishnan
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I am getting the following error when run the program in eclipse

java.lang.NoClassDefFoundError: jdk1/5/0_04
Exception in thread "main"



I tried with version j2sdk1.4.2 , it works fine.

could anyone help on this?

regards
Ganesh
 
John Jai
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you try recompiling with jdk1.5 first and then run the java command?
 
Ganesan Ramakrishnan
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried , but not working.
In my machine, the following jdk's are installed for various purposes,

1. jdk1.5.0_12
2. jdk1.5.0_04
3. j2sdk1.4.2
4. jdk1.3.1_07

In eclipse,
project properties -> Java build path -> execution environment - jdk1.5.0_04
In project properties -> java compiler -> compiler compliance level - 1.5
generated .class files compatibility - 1.5
source compatibility - 1.5

regards,
ganesh
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What command exactly are you typing in to run your program?

I suspect you are typing a path name, something like this:

java jdk1.5.0_04/MyClass

The name that you specify with the java command must be a fully-qualified class name, not a filename. You specify to Java in which directories to look for class files by setting the classpath. You can do that using the -cp switch. Something like this:

java -cp C:\MyProject\classes com.test.JRECheck5

Note: It is not a good idea to store your own source and class files in the JDK installation directory. Store them somewhere else, in a project directory that you make yourself.
 
John Jai
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You will get a UnsupportedClassVersion error rather than a ClassdefNotfound error when you try to execute java class files generated by different version. Seems more likely eclipse is not able to locate the generated .class file.

and why the error is java.lang.NoClassDefFoundError: jdk1/5/0_04 instead of java.lang.NoClassDefFoundError: com/test/JRECheck15. It should be the class name right?
 
Ganesan Ramakrishnan
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi John,
yes, JRECheck15 is a class name.
I am running the project using

rightclick the projectname -> Run as -> java application

regards,
Ganesh
 
John Jai
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's fine. My question was why the error pops up with the JDK name and not the class name as you have mentioned in your first post. You can try Jesper's method and see if the class gets executed with the installed JDK1.5 version using the cmd prompt. Just to ensure your jdk is installed fine.
 
Ganesan Ramakrishnan
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes jhon you are right,

i am getting the following error message when run
C:\jdk1.5.0_04\bin>java JRECheck
Exception in thread "main" java.lang.NoClassDefFoundError: JRECheck

could you tell me how to solve this problem, i already reinstalled twise in my machine.

the following exe i uninstall for java 1.5.0.4 from control panel,
j2se development ket 5.0 update 4
j2se runtime environment 5.0

any other exe's?

regards,
Ganesh
 
John Jai
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java command should be followed with fully qualified name. So it should include the package declaration.
So try like java com.test.JRECheck5. Hope you compiled like javac com/test/JRECheck5.java

 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to our Beginning Java forum.
 
Ganesan Ramakrishnan
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi John,

I tried , it works fine.
But in eclipse its not working
 
John Jai
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then something might be missing in the project setup which makes eclipse not to detect the class files. You can try deleting the generated class file. Clean the project and build again with the preferred jdk and try running it. Class files will be present in Eclipse project properties -> Java Build Path -> Source tab -> Default output folder.
 
Ganesan Ramakrishnan
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi John,

I tried out all you said, but i am getting same error message.

Regards,
Ganesh
 
Vimal Kumar Venugopal
Ranch Hand
Posts: 43
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for re-opening this topic.. But am getting the same error.. Any solution to this topic?

Lamiv,
USSR.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As you can read in the replies above, this kind of error happens because you are typing in a pathname on the commandline, not a class name.

The java command expects a fully-qualified class name, not a pathname (directory name + filename). If your class files are in a specific directory, then use the "-cp" option to set that directory as the classpath. For example:

java -cp C:\MyProject org.mypackage.MyProgram

(Note: Do not store your own project files under the JDK installation directory!).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!