Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to set up  classpath dynamically inside java class ??

Posted on 2002-06-14
8
Medium Priority
?
442 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
[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
  • 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
The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

 

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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

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…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

670 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