• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

/jre/lib/ext error

 
saloni jhanwar
Ranch Hand
Posts: 583
Firefox Browser Notepad Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



F:\Project\OCA7\Chapter10\java\search_classes\new>jar -cf Third.jar third

F:\Project\OCA7\Chapter10\java\search_classes\new>jar -tf Third.jar
META-INF/
META-INF/MANIFEST.MF
third/
third/Third.class
third/Third.java
third/Third.java.bak

F:\Project\OCA7\Chapter10\java\search_classes>javac Original.java

F:\Project\OCA7\Chapter10\java\search_classes>java Original
Exception in thread "main" java.lang.NoClassDefFoundError: third/Third
at Original.main(Original.java:6)
Caused by: java.lang.ClassNotFoundException: third.Third
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 1 more
 
gurpeet singh
Ranch Hand
Posts: 924
1
Fedora Java Netbeans IDE
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you have done everything right. infact something should have given you a hint. note that when you compiled Original using javac Original.java , it was ABLE to find Third class which you copied in /jre/lib/ext. but when you tried to run it using java Original it threw NoClassDefsFoundError. actually there are two paths of /jre/lib/ext in the installation directory of java. one is in jdk1.7.0 directory and the other one is in jre7 or 6 (whichever version you are using) directory. so to make the program run using java extension mechanism you ALSO have to copy your myjar.jar in the jre path. on my system the path was C:\Program Files\Java\jre6\lib\ext.

Try copying your myjar.jar here and see if it runs.
 
saloni jhanwar
Ranch Hand
Posts: 583
Firefox Browser Notepad Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
gurpeet singh wrote:you have done everything right. infact something should have given you a hint. note that when you compiled Original using javac Original.java , it was ABLE to find Third class which you copied in /jre/lib/ext. but when you tried to run it using java Original it threw NoClassDefsFoundError. actually there are two paths of /jre/lib/ext in the installation directory of java. one is in jdk1.7.0 directory and the other one is in jre7 or 6 (whichever version you are using) directory. so to make the program run using java extension mechanism you ALSO have to copy your myjar.jar in the jre path. on my system the path was C:\Program Files\Java\jre6\lib\ext.

Try copying your myjar.jar here and see if it runs.

Nice.
 
gurpeet singh
Ranch Hand
Posts: 924
1
Fedora Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well nice to you because i didn't knew the problem until i created the directory structure and ran the code. infact this is the first time i used java extension mechanism. i blindly believed this part while i was preparing for the exam without experimenting it. but thanks to you that now i have done.
 
saloni jhanwar
Ranch Hand
Posts: 583
Firefox Browser Notepad Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
gurpeet singh wrote:well nice to you because i didn't knew the problem until i created the directory structure and ran the code. infact this is the first time i used java extension mechanism. i blindly believed this part while i was preparing for the exam without experimenting it. but thanks to you that now i have done.


Fine,it's Ok.
 
gurpeet singh
Ranch Hand
Posts: 924
1
Fedora Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
saloni jhanwar wrote:
gurpeet singh wrote:well nice to you because i didn't knew the problem until i created the directory structure and ran the code. infact this is the first time i used java extension mechanism. i blindly believed this part while i was preparing for the exam without experimenting it. but thanks to you that now i have done.


Fine,it's Ok.


 
Ted North
Ranch Hand
Posts: 200
1
Java Python Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
gurpeet singh wrote:you have done everything right. infact something should have given you a hint. note that when you compiled Original using javac Original.java , it was ABLE to find Third class which you copied in /jre/lib/ext. but when you tried to run it using java Original it threw NoClassDefsFoundError. actually there are two paths of /jre/lib/ext in the installation directory of java. one is in jdk1.7.0 directory and the other one is in jre7 or 6 (whichever version you are using) directory. so to make the program run using java extension mechanism you ALSO have to copy your myjar.jar in the jre path. on my system the path was C:\Program Files\Java\jre6\lib\ext.

Try copying your myjar.jar here and see if it runs.


I just tried this on my MacbookPro sans Retina Display and it works. Of course there is no jre directory, unless you make it, to my knowledge. But, there are numerous /lib/ext directory structures on the Mac OS-X as well as, too much info., numerous JDKs, but anyway. I was surprised to see that using classpath switches was not necessary after putting the jar in my Java/Home/lib/ext directory. Very cool.

Thank-you for the food for thought.

Respectfully,

TN - rocking the command line like a man from a casket
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic