aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes /jre/lib/ext error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "/jre/lib/ext error" Watch "/jre/lib/ext error" New topic
Author

/jre/lib/ext error

saloni jhanwar
Ranch Hand

Joined: Feb 09, 2012
Posts: 583




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

Tell the difficulties that i am difficult.
gurpeet singh
Ranch Hand

Joined: Apr 04, 2012
Posts: 924
    
    1

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

Joined: Feb 09, 2012
Posts: 583

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

Joined: Apr 04, 2012
Posts: 924
    
    1

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

Joined: Feb 09, 2012
Posts: 583

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

Joined: Apr 04, 2012
Posts: 924
    
    1

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

Joined: Jan 02, 2012
Posts: 193
    
    1

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
 
Consider Paul's rocket mass heater.
 
subject: /jre/lib/ext error