?
Solved

classpath problems?

Posted on 2006-06-13
5
Medium Priority
?
609 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 500 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses
Course of the Month9 days, 4 hours left to enroll

764 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