Solved

classpath problems?

Posted on 2006-06-13
5
601 Views
Last Modified: 2010-08-05
OK, i have 2 jars, call them A.jar and B.jar

A.jar's purpose is to synchronize B.jar with some version of B.jar on the network in a specified location. If A.jar discovers that B.jar is out of synch with this other version, it replaces B.jar with the one on the network. Also, if B.jar is not present in the current directory it replaces it with B.jar from the network spot.  Both A.jar and B.jar live in the same directory.

Now, i exectute like this: java -classpath A.jar;B.jar someClass someparameter

However, I've found that when I do it this way, if B.jar is NOT originally in that directory when I launch Java it cannot find any classes in B.jar even if I copy it to the directory before I try to execute them.

Does that makes sense? let me clarify:

I start with A.jar ONLY in the directory. A.jar's job is to check for B.jar and when it does not find B.jar, it copies B.jar from a place on the network. It then needs to launch a class from B.jar in a thread and exit.

However, when either B.jar is not originally in the directory OR if B.jar is replaced by A.jar, the JVM throws a ClassDefNotFoundException for the class I'm trying to execute. If B.jar is not touched (its there AND its up to date), the launch works fine.

Any ideas? Thanks!
0
Comment
Question by:pedron
  • 3
  • 2
5 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 16896875
>>Does that makes sense?

Dependent jars need to be named in a jar's Class-Path entry in its manifest. If you use WebStart the process you're trying to achieve should happen transparently:

http://java.sun.com/j2se/1.5.0/docs/guide/javaws/developersguide/faq.html#204
0
 

Author Comment

by:pedron
ID: 16896958
Ok, I added the B.jar to A.jar's Class-Path entry in its Manifest file, but i got the same error. NoClassDefFoundException whenever I start out with NO B.jar in the directory.
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 125 total points
ID: 16896989
It need to be there or you need to load it dynamically. See

http://javaalmanac.com/egs/java.lang/LoadClass.html
0
 

Author Comment

by:pedron
ID: 16897086
THANKS! i have been sweating this hardcore lately. It works like a charm!
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 16897089
:-)
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
HashMap Vs TreeMap 12 49
Systems talking to each other 5 110
backtracking recursion  code 19 41
Cipher Configuration on Apache HTTPD 4 24
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now