We can set class path from command prompt also..
Runtime r=Runtime.getRuntime(); r.exec("set classpath=your desired path");
Not sure you can change it once the JVM has started.
Try it and see what happens.
You may need to build your own classloader that uses the paths you want it to use.
Not easily. Not directly.
Runtime.getRuntime().exec("set CLASSPATH=your desired path"); is not portable and while it sets the CLASSPATH environment variable in the child process, the child process immediately exits. You could set the CLASSPATH and run a program this way, but it's not portable.
System.setProperty("java.class.path", System.getProperty("java.class.path") + File.pathSeparator + "/my/path"); does not work because the system class loaders don't fetch the updated property.
That pretty much leaves us with extending or hacking a ClassLoader. Google can help. Here are some promising threads:
Thanks guys for showing some lines. I agree with jeff though that once JVM started will System classloader will able to pick the new Classpath , indeed custom Classloader can be a solution and I am going to try that. Thanks for those links quite helpful.
When using class loaders, if the system says that you cannot cast class X to class X because they're incompatible (with "X" and "X" being the exact same fully qualified class name with path) -- you're not losing your mind; you have class loader problems.
Knowing this can save you days of grief. But don't worry; you've already signed up for plenty of days of grief by deciding to play with class loaders. There will be plenty to go around! ;->
Hi. I have a form with list box : lst_product, datagridview : grd_order and button: btn_addline. lst_product has a list of product ids selected from database (MS Acess 2013) , grd_order is by default empty except for 2 headers and btn_addline adds rows to grd_order.
Private Sub btn_addline_Click(ByVal ...
Hi, as I was told that my code doesn’t scale well at all, I thought perhaps I’d try to get a better understanding of interfaces/abstract classes and classes and the relationship between them.
I don’t want at this stage work on a big separate project as I've already got plenty ...
OK, so HostGator for some reason no longer allows gcc/g++ access unless you have a Designated Server account, which is a lot of money to spend just to compile my "Hello World" program. Thus I figured I'd compile at home, then upload. Program is your regular old bare-bones Hello World ...