0

I have made a front end for a program which test java (foo.class) binary file for errors. The problem is that to test the file the folder must be in claspath. Now in my front end the foo.class file can be selected from any where in hard disk using a browse button but I am unable to append the selected location to class path in order to run the test. Since that folder can be different for each run of program therefore it needs to be kind of dynamic. Thanks.

Dr. Mian
  • 3,334
  • 10
  • 45
  • 69

1 Answers1

1

It is not possible to modify the classpath the JVM was started with. What you could do is implement your own classloader that can use a dynamic classpath. See this SO thread for more details

Community
  • 1
  • 1
Attila
  • 28,265
  • 3
  • 46
  • 55
  • There was a custom classloader in the program for which I was making frontend. So I selected the path of the file and assigned it to the classLoader. E.g. if a person select the file "/Users/mian/workspace/Program1.class" using browse button on fronted then the "/Users/mian/workspace/" is passed to the custom classloader and thus program1 is executed like a charm ;) Thanks. – Dr. Mian Jun 19 '12 at 11:15