Modify JVM environment variables on Linux at runtime
APACHE-2.0 License
Modify JVM environment variables on Linux at runtime
Add generated jar file as a library to your Java project
and put liblinuxenv.so in application's working directory
(or in the specifed custom location by -Djava.library.path
VM option)
public class LinuxEnvTest {
public static void main(String[] args) {
LinuxJVMEnvironment linuxJVMEnvironment = new LinuxJVMEnvironment();
linuxJVMEnvironment.setJVMEnvironmentVariable("Buka", "ZA GL JA", 1); // UTF-8 Support
String var = linuxJVMEnvironment.getJVMEnvironmentVariable("Buka");
System.out.println(var);
}
}
LinuxEnv changes JVM environment variables. System.getenv()
contains their copy
which is loaded when our application starts. You can manually update that map
by reflections after any modifications to maintain consistency.
However, it's not necessary if you don't want to use these variables from Java.
Releases are available here. You can also use maven (but you have to remember about the native library)
<dependency>
<groupId>net.dzikoysk</groupId>
<artifactId>linuxenv</artifactId>
<version>1.0.0</version>
</dependency>
<repository>
<id>panda-repository</id>
<name>Panda Repository</name>
<url>https://repo.panda-lang.org/</url>
</repository>
Default JDK8 location in the configuration section of build.sh
file is set to:
JDK_LOCATION = /usr/lib/jvm/java-8-oracle
You can execute build.sh
manually or by maven build. Generated files are placed in dist
directory.