Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #27775 > unrolled thread
| Started by | www <xsli2@yahoo.com> |
|---|---|
| First post | 2014-03-17 14:47 -0700 |
| Last post | 2014-03-18 23:29 +0000 |
| Articles | 8 — 5 participants |
Back to article view | Back to comp.lang.java.programmer
a Java classpath question www <xsli2@yahoo.com> - 2014-03-17 14:47 -0700
Re: a Java classpath question Knute Johnson <eternal@knutejohnson.com> - 2014-03-17 15:35 -0700
Re: a Java classpath question Joerg Meier <joergmmeier@arcor.de> - 2014-03-18 00:50 +0100
Re: a Java classpath question Arne Vajhøj <arne@vajhoej.dk> - 2014-03-17 22:39 -0400
Re: a Java classpath question Joerg Meier <joergmmeier@arcor.de> - 2014-03-18 11:15 +0100
Re: a Java classpath question Martin Gregorie <martin@address-in-sig.invalid> - 2014-03-17 22:55 +0000
Re: a Java classpath question Joerg Meier <joergmmeier@arcor.de> - 2014-03-18 00:52 +0100
Re: a Java classpath question Martin Gregorie <martin@address-in-sig.invalid> - 2014-03-18 23:29 +0000
| From | www <xsli2@yahoo.com> |
|---|---|
| Date | 2014-03-17 14:47 -0700 |
| Subject | a Java classpath question |
| Message-ID | <37209594-c0ba-44a7-ac07-6d7c0a57f594@googlegroups.com> |
Hi:
I have created my executable JAR file(abc.jar), within it a 3rd party JAR file(def.jar) is included. So my JAR file abc.jar includes def.jar from other people.
My code uses the code in def.jar like this:
find("nonsrc/dog.png");
On the command line, say in the directory /home/test/, there are two items:
abc.jar
nonsrc/ //containing dog.png file
So, if I am at /home/test directory, this command works well:
java -jar abc.jar // nonsrc/dog.png file was found by the Java
But I wish I am not restricted to be running only inside /home/test. So if I am at /home/ directory, I tried this command, but it failed:
java -classpath /home/test/ -jar ./test/abc.jar
The error message says that it cannot find nonsrc/dog.png file.
Please help.
[toc] | [next] | [standalone]
| From | Knute Johnson <eternal@knutejohnson.com> |
|---|---|
| Date | 2014-03-17 15:35 -0700 |
| Message-ID | <lg7tb2$vaf$1@dont-email.me> |
| In reply to | #27775 |
On 3/17/2014 14:47, www wrote:
> Hi:
>
> I have created my executable JAR file(abc.jar), within it a 3rd party
> JAR file(def.jar) is included. So my JAR file abc.jar includes
> def.jar from other people.
>
> My code uses the code in def.jar like this:
>
> find("nonsrc/dog.png");
>
> On the command line, say in the directory /home/test/, there are two
> items: abc.jar nonsrc/ //containing dog.png file
>
> So, if I am at /home/test directory, this command works well: java
> -jar abc.jar // nonsrc/dog.png file was found by the Java
>
> But I wish I am not restricted to be running only inside /home/test.
> So if I am at /home/ directory, I tried this command, but it failed:
>
> java -classpath /home/test/ -jar ./test/abc.jar
>
> The error message says that it cannot find nonsrc/dog.png file.
>
> Please help.
>
I didn't think you could put a jar file in another jar file and get to
it. Are you sure it isn't working because the file is in your directory
structure and that's where your program is reading it from?
--
Knute Johnson
[toc] | [prev] | [next] | [standalone]
| From | Joerg Meier <joergmmeier@arcor.de> |
|---|---|
| Date | 2014-03-18 00:50 +0100 |
| Message-ID | <17sp3bgki5e89.1q4gdw34ba4jp$.dlg@40tude.net> |
| In reply to | #27776 |
On Mon, 17 Mar 2014 15:35:16 -0700, Knute Johnson wrote: > I didn't think you could put a jar file in another jar file and get to > it. It's definitely possible, as servlet 3.0 does that on library jars. Liebe Gruesse, Joerg -- Ich lese meine Emails nicht, replies to Email bleiben also leider ungelesen.
[toc] | [prev] | [next] | [standalone]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2014-03-17 22:39 -0400 |
| Message-ID | <5327b1f0$0$297$14726298@news.sunsite.dk> |
| In reply to | #27778 |
On 3/17/2014 7:50 PM, Joerg Meier wrote: > On Mon, 17 Mar 2014 15:35:16 -0700, Knute Johnson wrote: > >> I didn't think you could put a jar file in another jar file and get to >> it. > > It's definitely possible, as servlet 3.0 does that on library jars. Java EE is a bit different from Java SE as the container may do some unpacking as part of the deployment process. Arne
[toc] | [prev] | [next] | [standalone]
| From | Joerg Meier <joergmmeier@arcor.de> |
|---|---|
| Date | 2014-03-18 11:15 +0100 |
| Message-ID | <1lzdkkj8jgknv$.kq09opbzhpmz$.dlg@40tude.net> |
| In reply to | #27780 |
On Mon, 17 Mar 2014 22:39:40 -0400, Arne Vajhøj wrote: > On 3/17/2014 7:50 PM, Joerg Meier wrote: >> On Mon, 17 Mar 2014 15:35:16 -0700, Knute Johnson wrote: >>> I didn't think you could put a jar file in another jar file and get to >>> it. >> It's definitely possible, as servlet 3.0 does that on library jars. > Java EE is a bit different from Java SE as the container may do some > unpacking as part of the deployment process. I didn't consider that, but you have a point. Liebe Gruesse, Joerg -- Ich lese meine Emails nicht, replies to Email bleiben also leider ungelesen.
[toc] | [prev] | [next] | [standalone]
| From | Martin Gregorie <martin@address-in-sig.invalid> |
|---|---|
| Date | 2014-03-17 22:55 +0000 |
| Message-ID | <lg7uhf$2i2$1@dont-email.me> |
| In reply to | #27775 |
On Mon, 17 Mar 2014 14:47:54 -0700, www wrote:
> Hi:
>
> I have created my executable JAR file(abc.jar), within it a 3rd party
> JAR file(def.jar) is included. So my JAR file abc.jar includes def.jar
> from other people.
>
> My code uses the code in def.jar like this:
>
> find("nonsrc/dog.png");
>
> On the command line, say in the directory /home/test/, there are two
> items:
> abc.jar nonsrc/ //containing dog.png file
>
> So, if I am at /home/test directory, this command works well:
> java -jar abc.jar // nonsrc/dog.png file was found by the Java
>
> But I wish I am not restricted to be running only inside /home/test. So
> if I am at /home/ directory, I tried this command, but it failed:
>
> java -classpath /home/test/ -jar ./test/abc.jar
>
> The error message says that it cannot find nonsrc/dog.png file.
>
If you use a -jar option to name the jar file containing your main class,
you should only need a -classpath if the jarfile content depends on
another jarfile in addition to the standard Java runtime class library.
IOW, without the -classpath dependency I'd expect a command more like
this to work:
java -jar /path/to/abc.jar classname
where 'classname' is the class which contains the main() method used to
start the program. You must name this class on the command line unless
the jarfile contains a manifest that names it.
What is in your manifest file?
--
martin@ | Martin Gregorie
gregorie. | Essex, UK
org |
[toc] | [prev] | [next] | [standalone]
| From | Joerg Meier <joergmmeier@arcor.de> |
|---|---|
| Date | 2014-03-18 00:52 +0100 |
| Message-ID | <vgayayc06uz2.1dq0oc2418ik1.dlg@40tude.net> |
| In reply to | #27777 |
On Mon, 17 Mar 2014 22:55:44 +0000 (UTC), Martin Gregorie wrote: > If you use a -jar option to name the jar file containing your main class, > you should only need a -classpath <BEEP> If you use -jar, -classpath is ignored, so logically nothing could come after that sentence part that makes sense ;) Liebe Gruesse, Joerg -- Ich lese meine Emails nicht, replies to Email bleiben also leider ungelesen.
[toc] | [prev] | [next] | [standalone]
| From | Martin Gregorie <martin@address-in-sig.invalid> |
|---|---|
| Date | 2014-03-18 23:29 +0000 |
| Message-ID | <lgaktc$8d8$1@dont-email.me> |
| In reply to | #27779 |
On Tue, 18 Mar 2014 00:52:08 +0100, Joerg Meier wrote: > On Mon, 17 Mar 2014 22:55:44 +0000 (UTC), Martin Gregorie wrote: > >> If you use a -jar option to name the jar file containing your main >> class, >> you should only need a -classpath > > <BEEP> > > If you use -jar, -classpath is ignored, so logically nothing could come > after that sentence part that makes sense ;) > OK: I so rarely use a -jar option that I'd forgotten that. So, he should be able to successfully run java -jar /home/test/abc.jar from any directory he cares to try it in. -- martin@ | Martin Gregorie gregorie. | Essex, UK org |
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.programmer
csiph-web