extension mechanism

X

xdevel1999

Hi,

I have a java .jar and put it into a: jre/lib/ext dir and so the
interpreter found it

java MyProg ---> executes well

but when I compile MyProg

it doesn't compile becasue it doesn't find the library in my .jar

so my question is: does extension mechanism work only with java
interpreter???
 
J

John B. Matthews

xdevel1999 said:
I have a java .jar and put it into a: jre/lib/ext dir and so the
interpreter found it

java MyProg ---> executes well

but when I compile MyProg

it doesn't compile becasue it doesn't find the library in my .jar

so my question is: does extension mechanism work only with java
interpreter???

I'm guessing that the compiler, perhaps located in a different
directory, doesn't know about the JRE's extension directory. You can
examine the system property java.ext.dirs to find out more. See also:

<http://mindprod.com/jgloss/ext.html>

In general, putting your own JARs in an ext directory is fraught with
peril. Like putting sawdust in a noisy transmission or taking steroids
for the flu, the immediate problem goes away but it'll come back to
haunt you.
 
K

Knute Johnson

xdevel1999 said:
Hi,

I have a java .jar and put it into a: jre/lib/ext dir and so the
interpreter found it

java MyProg ---> executes well

but when I compile MyProg

it doesn't compile becasue it doesn't find the library in my .jar

so my question is: does extension mechanism work only with java
interpreter???

Yes. On my Windows XP machine, there is a directory;

C:\Program Files\Java\jdk1.6.0_17\jre\lib\ext

You need your jar file in there as well if you want it to compile. The
other option is to put the jar file in the working directory, which is
really better in my opinion. And it makes for much easier distribution
of your program.
 
A

Arne Vajhøj

I have a java .jar and put it into a: jre/lib/ext dir and so the
interpreter found it

java MyProg ---> executes well

but when I compile MyProg

it doesn't compile becasue it doesn't find the library in my .jar

so my question is: does extension mechanism work only with java
interpreter???

Don't use ext dir. It makes both Java and application
updates problematic.

Use explicit classpath. Compiling: javac classpath.
Running: java classpath or manifest Class-Path directive.

Arne
 
L

Lew

Arne said:
Don't use ext dir. It makes both Java and application
updates problematic.

Not only updates, but installations, executions, deployments, particularly of
multiple applications on the same node.

The extensions directory feature is so you can essentially redefine the Java
platform itself, not so you can install a library for a particular
application. Like the CLASSPATH environment variable, the extensions
mechanism is far too global for ordinary use.
Use explicit classpath. Compiling: javac classpath.
Running: java classpath or manifest Class-Path directive.

Note: Most Java tools' "-classpath" command-line option can also be
abbreviated "-cp".

See
<http://java.sun.com/javase/6/docs/technotes/tools/windows/classpath.html>
<http://java.sun.com/javase/6/docs/technotes/tools/solaris/classpath.html>
<http://java.sun.com/docs/books/tutorial/deployment/jar/downman.html>

For the proper use of the extension mechanism, see
 
L

Lew

Roedy said:
there are two ext directories, one in the JRE and one in the JRE
buried inside the JDK. You need you put you jar in both.

More likely he needs to put his JAR in neither.
 
X

xdevel1999

I'm guessing that the compiler, perhaps located in a different
directory, doesn't know about the JRE's extension directory. You can
examine the system property java.ext.dirs to find out more. See also:

<http://mindprod.com/jgloss/ext.html>

In general, putting your own JARs in an ext directory is fraught with
peril. Like putting sawdust in a noisy transmission or taking steroids
for the flu, the immediate problem goes away but it'll come back to
haunt you.

Yes the java.ext.dirs doesn't have a setting to the jdk/jre/lib/ext
but
also if I override it with:

javac -extdirs /opt/jdk/jre/lib/ext MyProg.java

I have a compilation error of libraries not found

So I dont't understand two things:

1) why the java.ext.dirs doesn't have that library set to default
2) why that command doesn't work!!!

Thanks
 
J

John B. Matthews

xdevel1999 said:
I'm guessing that the compiler, perhaps located in a different
directory, doesn't know about the JRE's extension directory. You
can examine the system property java.ext.dirs to find out more. See
also:

<http://mindprod.com/jgloss/ext.html>

In general, putting your own JARs in an ext directory is fraught
with peril. Like putting sawdust in a noisy transmission or taking
steroids for the flu, the immediate problem goes away but it'll
come back to haunt you.
[Please omit signatures when responding.]
Yes the java.ext.dirs doesn't have a setting to the jdk/jre/lib/ext
but also if I override it with:

javac -extdirs /opt/jdk/jre/lib/ext MyProg.java

I have a compilation error of libraries not found

So I dont't understand two things:

1) why the java.ext.dirs doesn't have that library set to default

I don't know; my host OS integrates the JRE and JDK into a single
framework for each supported version. I usually just tell the IDE which
version to target, or I use a vendor-supplied control panel for the
command line.
2) why that command doesn't work!!!

I've never needed it; -cp does what I want. I see "-extdirs" is grouped
among the cross-compilation options as a way to exclude some code thtat
might otherwise be considered:

<http://java.sun.com/javase/6/docs/technotes/tools/windows/javac.html>

If you really have a case for using an ext directory, you need to
include the code's location in your configuration management plan. As a
practical matter, it's generally easier to track down a missing JAR than
to debug a wrong version being used.
 
L

Lew

Yes the java.ext.dirs doesn't have a setting to the jdk/jre/lib/ext
but
also if I override it with:

javac -extdirs /opt/jdk/jre/lib/ext MyProg.java

I have a compilation error of libraries not found

So I dont't understand two things:

1) why the java.ext.dirs doesn't have that library set to default
2) why that command doesn't work!!!

To number 1) - if you are running a different JRE from the one whose
extension was set, it won't work.
2) - You got the syntax wrong. That's not how to specify extension
directories to "javac".

Have you read the links we provided?

For javac, see
<http://java.sun.com/javase/6/docs/technotes/tools/solaris/
javac.html#options>

It really, really, really pays to read the documentation.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top