Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #27777

Re: a Java classpath question

Path csiph.com!usenet.pasdenom.info!aioe.org!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From Martin Gregorie <martin@address-in-sig.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: a Java classpath question
Date Mon, 17 Mar 2014 22:55:44 +0000 (UTC)
Organization A noiseless patient Spider
Lines 47
Message-ID <lg7uhf$2i2$1@dont-email.me> (permalink)
References <37209594-c0ba-44a7-ac07-6d7c0a57f594@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding 8bit
Injection-Date Mon, 17 Mar 2014 22:55:44 +0000 (UTC)
Injection-Info mx05.eternal-september.org; posting-host="e5160e2be48f1ea550cf61512446f525"; logging-data="2626"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/r+ILJ8vcz3kFbHxD1o9373O6gseSdtSY="
User-Agent Pan/0.139 (Sexual Chocolate; GIT bf56508 git://git.gnome.org/pan2)
Cancel-Lock sha1:0aKwWz21OGPrm94YQArvc1dnlZs=
Xref csiph.com comp.lang.java.programmer:27777

Show key headers only | View raw


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


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