views:

56

answers:

2

I've created a .jar containing some packages and I tried to put it into

c:\jdk\jre\lib\ext

but the java commnand does not find the package

If I, instead, put the .jar into

c:\jre\lib\ext

all works!

Why? The SUN's tutorial says that both the locations are good!

I saw that the extension mechanism works only for VM but not for the compiling process so for compilation if I want to use external packages I must compile with the -cp flag

Is that correct?

+1  A: 

JREs only use their own lib/ext directory. So you need to put the jars into the lib/ext directory of every JRE you want the library to work with. Using lib/ext is generally a bad idea.

I believe to get it to work with your compiler, you will need to place the jars in c:\jdk\lib\ext, not c:\jdk\jre\lib\ext.

Tom Hawtin - tackline
look at http://java.sun.com/docs/books/tutorial/ext/basics/install.html the dir is jdk\jre\lib\ext and not, like you say, c:\jdk\lib\ext
xdevel2000
+1  A: 

If I'm to take your two locations literally (i.e. no typo); a more likely scenario is that your JAVA_HOME isn't pointing to the JRE inside the JDK (c:\jdk\jre); but rather to a JRE somewhere outside your JDK (c:\jre).

As tackline posted above, you do in fact need to put the library in each and every JRE that you want to actually use, too. (Try installing Java3D sometime and observe what happens).

M1EK