Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Re: How to print out the currently used JAR file path to verify itis using right JAR?

Reply
Thread Tools

Re: How to print out the currently used JAR file path to verify itis using right JAR?

 
 
Arne Vajh°j
Guest
Posts: n/a
 
      11-06-2011
On 10/7/2011 9:56 AM, www wrote:
> My Java program running on linux machines fails on the code which is
> using 3rd party JAR file. The error message suggest that it is
> probably using an old version JAR file which I am not aware where it
> is. If it is using the NEW jar file, the program should pass.
>
> I hope to add some printing statements in the code to show the JAR
> file name and path right before the code crashes. Is there a way to do
> it?


The classpath should be explicit (no CLASSPATH env var) and so simple
or at least structured that it should not be a problem to know
where classes are loaded from.

There are several ways of getting the location of the
Foobar class:

Foobar.class.getProtectionDomain().getCodeSource() .getLocation().getPath()

Foobar.class.getClassLoader().getResource("Path.cl ass").getPath()

But to avoid future problems may I suggest that you in the
startup code find the jar for some of the critical libs
and check the version and if it is too old then you
print location and version and exit.

JarFile jar = new JarFile(fullfnm);
Manifest mf = jar.getManifest();
String ver = mf.getEntries().get(name).getValue("Implementation-Version");

should get a version number from the jar file for a
properly build jar file.

Arne
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Re: How to print out the currently used JAR file path to verify itis using right JAR? markspace Java 2 10-07-2011 06:17 PM
jaas.jar, jta.jar jdbc-stdext.jar missing from jdk1.5 RPM muttley Java 0 10-20-2005 02:40 PM
Differences of xercesImpl.jar, xercesImpl-J.jar, dom3-xercesImpl.jar ? Arnold Peters Java 0 01-05-2005 10:59 PM
Re: more Brash-itis - some truths Howard NZ Computing 4 02-24-2004 10:10 PM



Advertisments