The Artima Developer Community
Sponsored Link

Java Answers Forum
Changing classpath during runtime

5 replies on 1 page. Most recent reply: Mar 31, 2005 12:41 AM by Matthias Neumair

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 5 replies on 1 page
Matthias Neumair

Posts: 660
Nickname: neumi
Registered: Sep, 2003

Changing classpath during runtime Posted: Mar 22, 2005 8:50 AM
Reply to this message Reply
Advertisement
The title says all.

I want to add specific jar files during the execution of the program.

How do I accomplish that?

I know how to set the System property, but this does not have any effect.


Amol Brid

Posts: 43
Nickname: amolbrid
Registered: Feb, 2004

Re: Changing classpath during runtime Posted: Mar 23, 2005 5:06 AM
Reply to this message Reply
Why do you need this?

You can use Runtime.getRuntime().exec() method, but as soon as method returns the changes you made will be discarded.

I don't think there is any other way.

Regards,
Amol Brid.

Jonathan Tang

Posts: 3
Nickname: jdtang
Registered: Jan, 2005

Re: Changing classpath during runtime Posted: Mar 23, 2005 1:30 PM
Reply to this message Reply
Are you talking about plug-in architectures, that dynamically discover which plugin jars are available on execution, and then load that functionality in? I think those are usually done with a custom classloader. Can't give specifics, never implemented one myself, but you could check how Eclipse (http://www.eclipse.org/) handles them.

Matthias Neumair

Posts: 660
Nickname: neumi
Registered: Sep, 2003

Re: Changing classpath during runtime Posted: Mar 23, 2005 11:35 PM
Reply to this message Reply
@Amol: I don't want to start another instance of Java.
I want some sort of launcher, wich reads a configuration file to locate the central server where the program classes are stored and then launches the program.
The reason is that I don't want to use this endless classpath String in a batch file. Static classpaths in the Manifest don't work either, because not all of our customers have the same network architecture.
The program uses data stored on the local machine and data from a central server. To make updates easier I want to put the program code on the serber.
We have italian and german customers, the program directory is not allways the same, otherwise I would start the program directly from the server.

@Jonathan
So I need a custom classloader, that's what I was afraid of.

John Neale

Posts: 10
Nickname: rhino
Registered: Oct, 2003

Re: Changing classpath during runtime Posted: Mar 24, 2005 9:18 AM
Reply to this message Reply
Just an idea but have you investigated Java Web Start?

Matthias Neumair

Posts: 660
Nickname: neumi
Registered: Sep, 2003

Re: Changing classpath during runtime Posted: Mar 31, 2005 12:41 AM
Reply to this message Reply
Not yet.
I'll look into it.

Flat View: This topic has 5 replies on 1 page
Topic: How to use Perl functions in Java Previous Topic   Next Topic Topic: Applet please help!

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use