Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #27777
| From | Martin Gregorie <martin@address-in-sig.invalid> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: a Java classpath question |
| Date | 2014-03-17 22:55 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <lg7uhf$2i2$1@dont-email.me> (permalink) |
| References | <37209594-c0ba-44a7-ac07-6d7c0a57f594@googlegroups.com> |
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 |
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
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
csiph-web