Solved

classpath problems?

Posted on 2006-06-13
5
604 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

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
micro services spring boot application error 3 190
object oriented programming comparison 5 71
hibernate example issues from command prompt 10 41
mysql jsp example issue 32 35
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

773 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