java.home points to system java home but not the executed JVM
I am working with a library that for some reason requires three symlinks within the jre/bin directory. I want to create those symlinks at runtime, if they do not exist. However, I cannot do that, because
System.getProperty("java.home");
points to my system's java home. Since IntelliJ uses its bundled JRE by default (or a custom one), there seems to be no way to access the java.home of the running JVM. Even if I set the system's java home as the running JRE within the start configuration, this solution breaks on every other system and on my system as soon as the JAVA_HOME environment variable is changed. Is there a way to either set the java.home property to the currently running JRE home directory, or to set a custom environment variable to the currently running JRE home directory?
Please sign in to leave a comment.
>Since IntelliJ uses its bundled JRE by default (or a custom one), there seems to be no way to access the java.home of the running JVM.
JDK which IDE uses itself to run is not related in any way to the JDK you use to run your application and it does not influence or change any system properties (e.g. "java.home") for your application that you launch. java.home is a build-in Java system property, whose value is the JRE install directory and it would always show the jre directory of the JDK you you to run your application. If you run it from command line you would get the same result.
So there is no way to access the JVM, that is configured in the start-config of my application?
>So there is no way to access the JVM, that is configured in the start-config of my application?
I do not know what you are trying to do, and your application config, so I do not know if it is possible or not. I'm just stressing that IDE does not set/change any environment variables for jre/jdk that you have mentioned.