Link to home
Start Free TrialLog in
Avatar of jamwang
jamwang

asked on

Can you change classpath while the vm is executing?

Hi,

I have C app which uses JNI to bring up a vm to execute some methods.
Before, I brought up the vm, I set the class path in the VM's
initialization arguments and that works fine. But, the vm won't find the
class if you specify a class which is not in the class path. Is there
any way, you can change the class path while the vm is up in memory?

I tried a few ways. But, none seem to work. I first tried by resetting
the VM's init_args. This won't work unless you bring up another VM.
Another thing I tried was by calling putenv("classpath=exst classpath +
new cls path"). I thought this should work. But, it didn't. Does anyone
have comments on this or is there other ways of doing it?

Thanks,
Jamie
Avatar of jpk041897
jpk041897

getEnv and putEnv were removed from the VM in jdk 1.01 (the calls are still there, they just don't do anything) and completley removed in 1.1. Apperantly for security reasons, (much to the anoiance of Java CGI writters).

The purpose of this removal was to stop users from doing preciseley what you are attempting, this beeing a posible breach of security.

There is no way that will work for applets. For standalone apps, you could exec() a bat/shell script. that modifies the CLASSPATH variable and the launches the new app in a new shell.

The only marginaly acceptable solution I can think of would be to use packages.
ASKER CERTIFIED SOLUTION
Avatar of majkl
majkl

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial