jre/lib/ext and classpath

N

Naresh Agarwal

Hello,

If I put a Jar file in jre/lib/ext, should all of its dependent jar
files must be in jre/lib/ext only?

Or I can put a jar file in jre/lib/ext and its dependent jar files in
classpath??

thanks & regards,
Naresh Agarwal
 
D

David Segall

Posted and emailed:
Naresh Agarwal said:
Hello,

If I put a Jar file in jre/lib/ext, should all of its dependent jar
files must be in jre/lib/ext only?

Or I can put a jar file in jre/lib/ext and its dependent jar files in
classpath??

thanks & regards,
Naresh Agarwal
I thought my previous reply to this question was reasonably clear.
I'll reword it slightly and try again.

"Thanks to a response in this group and extensive googling I have
discovered two well kept secrets. The first is, if you launch your
application from a jar file, the jar file itself is the source of all
user classes and other user class path settings are ignored. The
second is that you can specify a space separated classpath in the jar
manifest file on a line beginning "Class-Path:" which will be used to
locate classes and resources.

No doubt Sun would deny they are secrets because they are documented
in the -jar option of the java command and in the Jar Manifest
Specification respectively but a tutorial on deploying Java
applications using jars would have been a big help."

If the above needs rewording to make it understood I would appreciate
some feedback. Having spent a couple of frustrating days finding the
information I would like to respond with a lucid post when others have
the same difficulty. Perhaps someone would like to put a tutorial on
their web site - Roedy?, Andrew?
 
A

Andrew Thompson

Posted and emailed:
...
I thought my previous reply to this question was reasonably clear.

(shrugs) So did I.
..Perhaps someone would like to put a tutorial on
their web site - Roedy?, Andrew?

...err. Dunno. I was about to ask the OP why the repost
(as it seems to me) earlier when I saw this ..new(?) post.
Then I thought I'd just get hassled by the "don't say
narsty things" brigade and decided not to bother..
 
R

Raymond DeCampo

David said:
Posted and emailed:


I thought my previous reply to this question was reasonably clear.
I'll reword it slightly and try again.

"Thanks to a response in this group and extensive googling I have
discovered two well kept secrets. The first is, if you launch your
application from a jar file, the jar file itself is the source of all
user classes and other user class path settings are ignored. The
second is that you can specify a space separated classpath in the jar
manifest file on a line beginning "Class-Path:" which will be used to
locate classes and resources.

No doubt Sun would deny they are secrets because they are documented
in the -jar option of the java command and in the Jar Manifest
Specification respectively but a tutorial on deploying Java
applications using jars would have been a big help."

David,

The above seems clear enough to me (although I wouldn't really call them
secrets myself), but the situation of the OP has discovered a hole in
your exposition. That is, jar files in the lib/ext of the JRE are
included in the (effective) classpath of any program run by the JVM.
(Assuming a specific property, the location of the ext directory, is not
set to something else.) So, for example, you could place your favorite
XML parser in the lib/ext and have it be used by any application running
from that JVM, whether they are run using -jar or not.

As far as your desire for a tutorial goes, take a look at the JAR Files
trail of the Java Tutorial from Sun:

<http://java.sun.com/docs/books/tutorial/jar/index.html>

HTH,
Ray
 
R

Roedy Green

If I put a Jar file in jre/lib/ext, should all of its dependent jar
files must be in jre/lib/ext only?

Or I can put a jar file in jre/lib/ext and its dependent jar files in
classpath??

I would expect both to work, but you could have found that out by
experiment faster than asking. So I suppose you are asking if doing
so is good form.

My thinking is the ext is for stuff you don't mind exposing to
everyone.

The classpath is more fragile, and normally should be almost empty.
 
R

Roedy Green

Perhaps someone would like to put a tutorial on
their web site - Roedy?, Andrew?

I think that is mentioned both in the classpath and the jar entries
int he Java glossary.
 
D

David Segall

Raymond DeCampo said:
David,

The above seems clear enough to me (although I wouldn't really call them
secrets myself), but the situation of the OP has discovered a hole in
your exposition. That is, jar files in the lib/ext of the JRE are
included in the (effective) classpath of any program run by the JVM.
(Assuming a specific property, the location of the ext directory, is not
set to something else.)
I noticed the hole but I was not sure if lib/ext was on the effective
classpath or the directory containing the jar was on the effective
classpath. Is lib/ext always on the classpath and is that documented
somewhere?
As far as your desire for a tutorial goes, take a look at the JAR Files
trail of the Java Tutorial from Sun:

<http://java.sun.com/docs/books/tutorial/jar/index.html>
That is the source of most of my information about Jar files but,
because it is comprehensive, it is difficult for a beginner to glean
just the information that is needed to deploy a jar file. I think
there is a need for a cookbook style tutorial on the subject.
 
R

Raymond DeCampo

David said:
That is the source of most of my information about Jar files but,
because it is comprehensive, it is difficult for a beginner to glean
just the information that is needed to deploy a jar file. I think
there is a need for a cookbook style tutorial on the subject.

A fair criticism.

Ray
 
D

David Segall

Roedy Green said:
I think that is mentioned both in the classpath and the jar entries
int he Java glossary.
You are right. The Class-Path section of the jar entry contains the
information I posted and much more. Your revelation that Class-Path
only works in 1.5 explains why the information was so difficult to
find. May I suggest that you provide links to this section from the
classpath page and from an appropriate top-level heading.
 
R

Raymond DeCampo

David said:
You are right. The Class-Path section of the jar entry contains the
information I posted and much more. Your revelation that Class-Path
only works in 1.5 explains why the information was so difficult to
find. May I suggest that you provide links to this section from the
classpath page and from an appropriate top-level heading.

What are you talking about when you say that "Class-Path
only works in 1.5". Sounds like FUD to me.

Ray
 
K

Kimmo Tuukkanen

David said:
I noticed the hole but I was not sure if lib/ext was on the effective
classpath or the directory containing the jar was on the effective
classpath. Is lib/ext always on the classpath and is that documented
somewhere?

No, it is not "on the classpath", but instead it is one of the places
where JVM looks for the classes. The classpath is another place. The
lib/ext directory is for "installed extensions" (or "optional packages"
as they've once again renamed things in 1.5), which mean the libraries
that extend the basic Java core. For example, Java Communications API is
an extension.

The documentation and tutorial is here:

http://java.sun.com/j2se/1.5.0/docs/guide/extensions/
http://java.sun.com/docs/books/tutorial/ext/

I guess the following page is the best answer to your questions:

http://java.sun.com/docs/books/tutorial/ext/basics/load.html
 
R

Raymond DeCampo

David said:
If so, it's not my FUD. It is at http://mindprod.com/jgloss/jar.html
under Class-Path. Is Roedy wrong?

Yes, he is wrong. And it is not the first time I've caught him
spreading FUD. Do you really think that executing jar files using -jar
has been broken up until 1.5 where the jar files have external dependencies?

I have witnessed it working on 1.3 and 1.4 and I would imagine it has
worked since the introduction of the Class-Path entry in the manifest
format. It wouldn't surprise me to learn that it goes all the way back
to 1.1.

Ray
 
R

Roedy Green

You are right. The Class-Path section of the jar entry contains the
information I posted and much more. Your revelation that Class-Path
only works in 1.5 explains why the information was so difficult to
find. May I suggest that you provide links to this section from the
classpath page and from an appropriate top-level heading.

It is linked. It is just you are overwhelmed with information.
 
R

Roedy Green

If so, it's not my FUD. It is at http://mindprod.com/jgloss/jar.html
under Class-Path. Is Roedy wrong?

I use macros that automatically update to point you to various places
in the current JDK. That is not meant to imply that this stuff did not
work in previous JDKs. If there is particularly misleading wording,
please point it out.
 
R

Roedy Green

Yes, he is wrong. And it is not the first time I've caught him
spreading FUD.

Please at least quote me if you want to accuse me.

Please be specific with both your charges. I can't very well correct
the entries if I don't know the sentences you are referring to.
 
R

Roedy Green

Yes, he is wrong. And it is not the first time I've caught him
spreading FUD.

FUD mean Fear Uncertainty and Doubt. A marketing tactic to freeze the
buyer from making a decision by leaving an impression that a better
product might be available imminently, and that there are mysterious
fatal flaws with the existing ones.

Saying something erroneous is not the same thing as spreading FUD.
 
R

Roedy Green

You are right. The Class-Path section of the jar entry contains the
information I posted and much more. Your revelation that Class-Path
only works in 1.5 explains why the information was so difficult to
find.


The relevant sentences from http://mindprod.com/jgloss/jar.html are:

According to Sun's JAWS FAQ, in JDK 1.5,
Java Web Start still does not support Class-Path.
Up until JDK 1.5, java.exe too ignored this entry.


Note this bug report, which sun closed, as evidence I did not make
this up.

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4356783
 
D

David Segall

Roedy Green said:
I use macros that automatically update to point you to various places
in the current JDK. That is not meant to imply that this stuff did not
work in previous JDKs. If there is particularly misleading wording,
please point it out.
"According to Sun's JAWS FAQ, in JDK 1.5, Java Web Start still does
not support Class-Path. Up until JDK 1.5, java.exe too ignored this
entry."

I assumed from the above sentence that Class-Path did not work prior
to JDK 1.5 and said so in a post in this thread. Ray disagreed.
If Ray is right then I, at least, was misled.
 

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,774
Messages
2,569,596
Members
45,143
Latest member
DewittMill
Top