Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

classpath problems?

Posted on 2006-06-13
5
Medium Priority
?
611 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
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…
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:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

610 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