• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

finding classpath from other (non java) application

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

i provided a plugin for adobe acrobat which is written in java. so C/C++ accesses my plugin through JNI.

following problems:
1) i need to set the classpath to the .jar which represents my plugin (otherwise ClassNotFoundDef error). the directory of this .jar is not static so i cannot hardcode the respective path into my JNI code.
2) i too provided an installer which sets up plugins directory, this installer is written in java so i cannot set up systems CLASSPATH or some other variable (like PATH_TO_MY_PLUGIN) persistently, which can easily be accessed from C++ code.

my ideas:
1) my installer could write into a properties file which has got the path information as entry, but this states again the problem how this properties file is going to be found for this i could try to find out some relations between systems envs and java properties (TEMP <-> java.io.tmpdir), but that seems to be brittle as well. anyways TEMP is for temporary stuff and my plugin path property file should be persistent. so i would misuse environment variables.
2) scan file system for my plugin-jar to find out the path. that solution seems to me to be very ugly.
3) using JNI inside my installer to call up C/C++ code and thus to set up environment variable PATH_TO_MY_PLUGIN, which still is not applicable that this environment variable gets lost after reboot (i think at least).

so have you got any other (better) ideas?

thanks a lot!
[ September 15, 2006: Message edited by: manuel aldana ]
 
Ranch Hand
Posts: 1970
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What about Preferences API? You could call it from your Java installer and from your JNI Java invocation code.
[ September 18, 2006: Message edited by: Peter Chase ]
 
manuel aldana
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you! it works fine for me.

before i did not know that there was an API which abstracts system specific persistent settings (like windows registry or hidden files).
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic