1

I have a condition in cpp saying if JVM is not running, I create a JVM and add all the Classpaths. On the other hand, if JVM is already running I need to add those classpaths to existing JVM. Though I need to make these changes in cpp only.

For example

if (this->pjvm == NULL){
   creating JVM using ptrfCreateJavaVM
}
else{
??
}
Stack Danny
  • 7,754
  • 2
  • 26
  • 55
Giri Ar
  • 11
  • 1
  • [This](https://stackoverflow.com/questions/2942536/is-the-java-classpath-final-after-jvm-startup) is a good read for what you want to do. – cmoetzing Apr 17 '19 at 06:30
  • Thank you for the quick response. The above specified says it is possible to add classpaths during runtime. But could you please guide me on how to add it using cpp – Giri Ar Apr 17 '19 at 06:41
  • 1
    This is a hard to answer question. As the post linked in cmoetsing's comment shows it, there is no clean and neat way to externally change the classpath of a running *standard* JVM. And your question refers to a `ptrfCreateJavaVM` that neither I nor Google know anything about. Long story short, you need either a specialized JVM or a standard JVM with a specialized ClassLoader, and a custom protocol to change the classpath at runtime. Not really simple. It would probably be simpler to stop the running JVM and start a new one... – Serge Ballesta Apr 17 '19 at 07:31
  • Thank you for the reply. i Do not need to completely change the classpath. I need to add it to already running standard JVM and not create another JVM. – Giri Ar Apr 22 '19 at 06:00

0 Answers0