Linux command to get current value of java.io.tmpdir
Asked Answered
S

5

21

I need a Linux command to get current value of java.io.tmpdir Also can you tell me the command to get all the system propeties.

Shaveling answered 10/4, 2012 at 17:5 Comment(1)
do you mean environment variables by "system properties"?Lemon
M
36

JDK provides tools with which you can achieve your goal. Using the specified command, you can display the value of a system variable java.io.tmpdir.

jinfo <process id> | grep "java.io.tmpdir"

The <process id> is the number of the java process for which you want to display the value of the system variable. Id of the java process you can get by using the jps tool, which list all java processes running on your machine.

To see all system variables of the java process, please use this command

 jinfo <process id>

All JDK tools are located in $JAVA_HOME/bin directory.

java.io.tmpdir is one of java system properties, so its value exists only inside jvm. To find out what is the value of java.io.tmpdir property you can also write a simple program in java. It may look something like this piece of code:

public class JSystemProperties {
    public static void main(String[] args) {
        System.getProperties().list(System.out);
    }
}

The code above will print all java system properties, but you can modify this to print only one system property with name you pass through args array (using System.getProperty(key) method). After you compile this class you can create script (which will run compiled java class) that can be treated as Linux command to get current values of java system properties.

Mystic answered 7/3, 2014 at 10:20 Comment(3)
Error attaching to process: sun.jvm.hotspot.debugger.DebuggerException: Can't attach to the processOakum
try to switch to root user or to the same user who started JVMMystic
This program required import java.util.Properties. I think it make sense to edit this to System.getProperties().list(System.out);Schlessel
I
14

For black box Java applications I've deployed in the past, I have sometimes been able to find the value of java.io.tmpdir by executing the following command:

ps -ef | grep java.io.tmpdir

Particularly with tomcat apps, you may get an output like this:

-Djava.io.tmpdir=/usr/local/tomcat/temp

Ignatzia answered 19/10, 2015 at 21:28 Comment(0)
L
2

For temp dir: there is a good answer here.

For all environment variable, try env command.

Lemon answered 10/4, 2012 at 17:21 Comment(0)
C
2

Run:

java -XshowSettings

and look for the value of "java.io.tmpdir ="

Property settings:
file.encoding = UTF-8
file.separator = /
java.class.path = 
java.class.version = 61.0
java.home = /usr/lib/jvm/zulu17-ca
java.io.tmpdir = /tmp  # <---- HERE
Capital answered 25/7, 2023 at 23:18 Comment(0)
K
1

Recommended tool now is jcmd, use it like :

jcmd $pid VM.system_properties | grep java.io.tmpdir
Komsomolsk answered 15/2, 2019 at 6:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.