Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to set up  classpath dynamically inside java class ??

Posted on 2002-06-14
8
Medium Priority
?
444 Views
Last Modified: 2013-11-23
Hi
I want to set up classpath inside java class dynamically. I have tried to use System.setProperty("java.class.path", "my class path string ") to set classpath dynamically. But it is not working. How to set it dynamically from java class ?? Thanks , gary
0
Comment
Question by:garyshi
  • 4
  • 3
8 Comments
 
LVL 1

Expert Comment

by:nixj14
ID: 7078107
You're in the same situation as I am in, so you may want to refer to the question that I will be asking.  To what I've researched and found from associates, you can not redefine a classpath once a VM has been instantiated.  You can however, define classes (or load classes) while the vm is loaded.  Look at the Classloader and System objects.


0
 
LVL 9

Expert Comment

by:Venci75
ID: 7078174
have you tried:
String cp = System.getProperty("java.class.path");
cp += ";new_jar.jar";
System.setProperty("java.class.path", cp);
0
 

Author Comment

by:garyshi
ID: 7078376
Hi nixj14,
Could you tell me main steps I should do for set classpath or load class ?? or If you have example code or few lines inportant codes for this problem, could you send them to me ?? Thanks so much.  I have to handle this problem as soon as possible. Otherwise I am worry ....

Venci75
I have tried the way you mention. It is not working.
Thanks all for you guy

Best Regards
Gary
gary2shi@yahoo.com
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:garyshi
ID: 7078716
Hi nixj14,
Thanks for giving me a link. But I can not open this link.  I guess it need a hotmail login first or it will check hotmail user, then go to some page. Could you copy them to me ?  Your hlep will be appreciated very much. Gary
0
 
LVL 1

Accepted Solution

by:
nixj14 earned 300 total points
ID: 7078799
0
 

Author Comment

by:garyshi
ID: 7079155
Hi nixj14,
Thanks for your help. I have run your example and it works fine.
Now I can load another class and run it from this classloader/example. But when I run one java class, it need some other java classes, like help.jar, util.jar. I have to put these jar files into classpath . There is no way to add these jar files into class path dynamically or use classloader to add these jar files into classpath ??  Again thanks for your help.
Gary
0
 
LVL 1

Expert Comment

by:nixj14
ID: 7079364
Yeah, I'm running through a similar problem.  I was able to download some good source to add jars into your classpath.

Try this

http://gcc.gnu.org/ml/java/2000-10/msg00002.html
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

886 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