• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Appending folder to classpath at runtime

 
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there anyway to "legally" change the Java classpath
during program execution? Or some way to tell the JDK classloader
where to look for user specified files ?

Thanks

Zak Nixon
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Taken From : Zak Nixon
Is there anyway to "legally" change the Java classpath
during program execution? Or some way to tell the JDK classloader
where to look for user specified files ?


No you cannot change the classpath dynamically with System.setProperty("java.class.path",newClassPath).

The way to achieve the effect is to create a java.net.URLClassLoader with the extra paths that you want to be searched during runtime.

HTH,
Arjun K
 
Zak Nixon
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Arjun K.

By using the URLClassLoader class, I was successfully able to
amend my classpath and load my classes as needed.

I appreciate the help and guidance.

Zak
 
We begin by testing your absorbancy by exposing you to this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic