lundi 17 mars 2014

Re: a Java classpath question topic




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





Aucun commentaire:

Enregistrer un commentaire