Solved

How to set up  classpath dynamically inside java class ??

Posted on 2002-06-14
8
438 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
Technology Partners: 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!

 

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 100 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

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
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 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.

729 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