Java environment variables

Hi,
Just curious... What are the different environment variables that Java looks at, and what is the purpose for each of them?? To clarify that I'm talking about, I think some of them are JAVA_HOME, JAVAC(?), CLASSPATH, etc.
Thanks

There are three environment variables that Java generally uses:
1. PATH
2. CLASSPATH
3. JAVA_HOME
PATH is actually a windows environment variable where you specify the paths of executable files. For Java, this environment variable helps it locate java compiler, java runtimes - java, javaw and other tools in the JDK.
CLASSPATH is specific to Java; it helps Java tools find Java class files
JAVA_HOME is used by Java Applications to point to the directory where JDK is installed.
For the current status of environment variables in Windows, run a command prompt and type 'set' (without quotes) followed by enter. Windows will then list all environment variables defined.

Similar Messages

  • JAVA ENVIRONMENTAL VARIABLE AND PATH SETTINGS

    Hi all,
    I am having a pecuilar problem with java environment variables and setting the path.
    I am trying to install and check the instalation using some pre-provided batch commands from Open GTS.
    The error log is as below .
    ** Found 2 Error(s)!
    1) The 'PATH' environment variable points to the JRE, rather than the JDK.
       [Reason: The 'PATH' environment variable points to the JRE (Java Runtime
         Environment), rather than the JDK (Java Developer Kit).  The JDK already
         contains the JRE, so a separate JRE insallation  is not necessary.]
       [Fix: Set the 'PATH' environment variable to point to the JDK installation bi
    n
         directory.]
    2) 'JAVA_HOME' does not match the Java installation 'PATH' directory 'C:\Program
    Files\Java\jre6'.
       [Reason: The version of Java referenced in the executable 'PATH' environment
         variable does not match 'JAVA_HOME'.]
       [Fix: Make sure both the 'JAVA_HOME' and 'PATH' environment variables point t
    o the
         same installed JDK.]
    No warnings reported
    Further more these may help understand better
    C:\Dush\Workspaces\JavaWorkspace\OpenGTS>echo %JAVA_HOME%
    C:\Program Files\Java\jdk1.6.0_03
    C:\Dush\Workspaces\JavaWorkspace\OpenGTS>path
    PATH=C:\Program Files\PC Connectivity Solution\;C:\WINDOWS\system32;C:\WINDOWS;C
    :\WINDOWS\System32\Wbem;C:\Program Files\apache-ant-1.7.0\bin;C:\Program Files\J
    ava\jdk1.6.0_03\bin;C:\Program Files\MySQL\MySQL Server 5.0\bin;C:\Dush\Workspac
    es\JavaWorkspace\OpenGTS\bin;
    C:\Dush\Workspaces\JavaWorkspace\OpenGTS>The resolution suggests that the path point to the same instance of jdk installation but that has already been done,
    I do not understand from where does the
    C:\Program Files\Java\jre6 path get set.
    Please suggest..

    dushdushyant wrote:
    ** Found 2 Error(s)!
    1) The 'PATH' environment variable points to the JRE, rather than the JDK.
    [Reason: The 'PATH' environment variable points to the JRE (Java Runtime
    Environment), rather than the JDK (Java Developer Kit).  The JDK already
    contains the JRE, so a separate JRE insallation  is not necessary.]
    [Fix: Set the 'PATH' environment variable to point to the JDK installation bi
    n
    directory.]
    2) 'JAVA_HOME' does not match the Java installation 'PATH' directory 'C:\Program
    Files\Java\jre6'.
    [Reason: The version of Java referenced in the executable 'PATH' environment
    variable does not match 'JAVA_HOME'.]
    [Fix: Make sure both the 'JAVA_HOME' and 'PATH' environment variables point t
    o the
    same installed JDK.]
    No warnings reported
    C:\Dush\Workspaces\JavaWorkspace\OpenGTS>echo %JAVA_HOME%
    C:\Program Files\Java\jdk1.6.0_03
    C:\Dush\Workspaces\JavaWorkspace\OpenGTS>path
    PATH=C:\Program Files\PC Connectivity Solution\;C:\WINDOWS\system32;C:\WINDOWS;C
    :\WINDOWS\System32\Wbem;C:\Program Files\apache-ant-1.7.0\bin;C:\Program Files\J
    ava\jdk1.6.0_03\bin;C:\Program Files\MySQL\MySQL Server 5.0\bin;C:\Dush\Workspac
    es\JavaWorkspace\OpenGTS\bin;
    Put the java home bin folder on the path before %SYSTEMROOT%\system32
    set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_03
    set PATH=%JAVA_HOME%\bin;%PATH%

  • How do i get value of Environment variables from a java program?

    Hai,
    I have a setup file wherein i set the path for the root directory , in the following way.
    setenv TPEROOT "/home/systpe/khurram/changes"
    when i give echo $TPEROOT
    the path , home/systpe/khurram/changes , is displayed on the console
    If i want to assign the $TPEROOT to a string variable str in my java program , then how can i do it.
    I want to use the value of the environment variable in my program.
    Any help in this regard would be very useful
    Thanks
    khurram

    java -DTPEROOT=$TPEROOT myőackage.myclass myargs

  • Returning/passing Java script variable/value to PL/SQL environment

    Hi,
    Can someone give me a sample code about how to return a Java script variable to PLSQL environment?
    for example, I have a javascript function that returns timestamp in milisecond, I then want to write PLSQL code to call this java script function and save its value in a number-typed plsql variable for further calculation, I dont know how the two scripting language communicate.
    Thank you very much
    Binh
    null

    This is quite simple.
    I assume that you are able to define html form side through pl/sql. Suppose your new pl/sql value is v_time then in the procedure that you write include one more statement
    htp.p('<Input type=hidden name="v_time" value="">');
    and also in the form invocation,
    htp.p('<form name=app method=post action="time_handler" onSubmit="return false;">');
    and to the end you must be having a submit
    to it attach a onClick function that calls
    simply our validate function..
    eg htp.p('<Input type=submit value="process"
    onClick="validate();">');
    Include in the head portion
    the following script using htp.p procedure
    function validate()
    app.v_time.value=<calculated value>;
    return app.submit();
    Hope this helps.
    Nat
    null

  • Unable to access value in System Environment Variable using Java

    I am using Java code to get the value of a System Environment Variable using the Runtime, Process java classes.
    The code works fine in tomcat, but when deployed in 9ias the code is unable to retrieve the value stored in the System environment variable in Windows 2000.

    Thanks for the comment steve, here is the code which i am using.
         public String getEnvironmentVariable()
                   // This will get the FEDREP_HOME environment variable
                   String FEDREP_HOME = null;
                   Process p = null;
                   Runtime rt = Runtime.getRuntime();
                        try {
                             // invokes a shell-command to retrieve FEDREP_HOME variable
                             String OS = System.getProperty("os.name").toLowerCase();
                                  // Get the Windows 95 environment variable
                                  if (OS.indexOf("windows 9") > -1)
                                            p = rt.exec( "command.com /c echo %FEDREP_HOME%" );
                                  // Get the Windows NT environment variable
                                  else if (OS.indexOf("nt") > -1)
                                            p = rt.exec( "cmd.exe /c echo %FEDREP_HOME%" );
                                  // Get the Windows 2000 environment variable
                                  else if (OS.indexOf("2000") > -1)
                                            p = rt.exec( "cmd.exe /c echo %FEDREP_HOME%" );
                                  // Get the Windows XP environment variable
                                  else if (OS.indexOf("xp") > -1)
                                            p = rt.exec( "cmd.exe /c echo %FEDREP_HOME%" );
                                  // Get the unix environment variable
                                  else if (OS.indexOf("linux") > -1)
                                            p = rt.exec( "sh -c echo $FEDREP_HOME" );
                                  // Get the unix environment variable
                                  else if (OS.indexOf("unix") > -1)
                                            p = rt.exec( "sh -c echo $FEDREP_HOME" );
                                  // Get the unix environment variable
                                  else if (OS.indexOf("sunos") > -1)
                                            p = rt.exec( "sh -c echo $FEDREP_HOME" );
                                  } else
                                            System.out.println("OS not known: " + OS);
                             // set up to read subprogram output
                             InputStream is = p.getInputStream();
                             InputStreamReader isr = new InputStreamReader(is);
                             BufferedReader br = new BufferedReader(isr);
                             // read output from subprogram
                             FEDREP_HOME = br.readLine();
                             br.close();
                        } catch(Exception ex)
                                  System.out.println("Error when getting FEDREP_HOME environment variable");
                                  ex.printStackTrace();
              return(FEDREP_HOME);

  • Overwrite java parameters with environment variables or other mechanism???

    I am using several java programs on my machine. Each of them uses some deeply nested startup script so I have no chance to modify the parameters of the java command.
    I would need to change certain parameters though, e.g. the heap size or certain system properties.
    Is there a way to do this by e.g. setting environment variables or modifying a user-specific configuration file?
    I am using jdk 1.5.0_06 on Linux (Ubuntu).

    Well the ones I am dealing with do not, unfortunately.
    I am also interested in a general way to tune the JVM settings without modifying each and every call statement.
    Surely there must be some mechanism to achieve this??

  • Java and UNIX environment variables

    Hi folks,
    am I right when I say that it is not possible to access UNIX environment variables from Java (these ones delared by the export statement)?
    Cheers,
    Heiko

    Yes.. Since some OS do not have the  concept of environment variables,it is directly not possible.
    But using the method System.getProperties you can get
    some inf about the environment.
    the following links may be of some help to you
    http://www.javaworld.com/javaworld/javaqa/2001-07/01-qa-0706-env.html
    http://www.jguru.com/faq/view.jsp?EID=11422

  • How does java access user specific environment variables ?

    Hi,
    I'm running a java application on a W2K o/s. My application needs to be able to access the user environment variables in Windows but I don't know how to do this. Can anyone help ?
    Thanks.

    http://www.rgagnon.com/javadetails/java-0150.html

  • Environment variables for Java

    Hi,
    I installed jdk1.6.0_02 from Sun, and set the following environment variables:
    export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11:/usr/games:*/home/username/jdk1.6.0_02/bin*
    export LD_LIBRARY_PATH=/home/username/jdk1.6.0_02/lib
    export JAVA_HOME=/home/username/jdk1.6.0_0
    I issue the following commands:
    which javac
    */home/username/jdk1.6.0_02/bin/javac*
    which java
    */usr/bin/java*
    why is it referring to */usr/bin/java* instead of */home/username/jdk1.6.0_02/bin/java*
    How can I solve this problem under Ubuntu 8.04.
    Thank you in advance,
    --Blaise
    Edited by: Blaize on Jul 19, 2008 5:49 AM

    Blaize wrote:
    Ok */ust/bin* is needed in the PATH. Why it affected java but not javac then?
    Provide an instructive solution or an instructive comment if you have.I should have thought it would have been fairly obvious that it was because javac was not in /usr/bin (and that it would have been just as easy to be certain, i.e. type "ls /usr/bin/javac"), but I guess not.
    I also would have thought, that it should be fairly obvious that a search path will always be read in a specific order (after all that is one of the reasons to have one, so that command searches aren't random), and, extrapolating from there, that it should be fairly obvious, considering the problem observed, that that search order was from left to right, but again, I guess not.
    Use your head for something other than a paper weight, and maybe you wouldn't need to become either defensive or aggresive, but, once again, that must be something that's beyond you.
    Learn how to type "How to configure path environment variable" into Google, and maybe the same would apply, but, once again, that is probably something that's beyond you.

  • Unable to start java tools - Error : Environment variable JAVA_HOME not set

    hi all,
    I am not able to start the java tool - Visual Admin, Configtool, etc in the solaris Bash shell.
    I was given authorizations on solaris and i'm able to view the logs and browse in solaris boxes,
    But, when i try to start Visual Admin, it says" ERROR environment variable JAVA_HOME not set "
    Since,my colleagues are using this tool for years, how come the environment variable is not set only for my user profile ?
    Is it like the environment variable has to set seperately for every user profile ?
    Do i need to set it initially for my profile eventhough it is working for others ?
    i am confused..please help.
    Addy

    Nicholls, Thanks for your quick reply.
    Ofcourse, I use my login ID to use java tools and they use their's obviously.I don't use <SID>adm.
    We WRQ reflection for X-Windows and Putty for Command line Solaris Access.
    When i try to use VA through the X-Window tool WRQ reflection, I am not able to start the tool.
    My doubt here is, Do we need to setup the environment variable for every new user initially for the first time ? ( I am a new user for this environment )
    Supposing if i need to setup the environment variable, do i need to set it up for the all the Solaris Boxes i use ?
    I am able to browse through the files.when i try to start the VA by giving ./go i am not able to start it up.
    Appreciate your time and valuable replies.
    Addy

  • How to read Environment Variable in Java.

    Hi,
    I am trying to read a environment variable $TMP which has a value of /apps/bea/pt847/psoft5/tmp in UNIX.
    I have written the following code and getting Null pointer exception when calling the method logmessage. Any help with reading environment variable is appreciated.
    public static void logMessage(String message) {
           SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss ");
           Date now = new Date();
           Properties p = null;   
           try
              p = getEnvVars("$TMP");
              System.out.println("the current value of TEMP is : " + p.getProperty("$TMP"));
           catch (Throwable e) {
              e.printStackTrace();
           try
           BufferedWriter os = new BufferedWriter(new FileWriter("/tmp/pscas_signon_log.txt", true));
           os.write(formatter.format(now));
           os.write(message);
           os.write("\n");
           os.write("tmp_env = " + p.getProperty("$TMP"));
           os.write("\n");
           os.close();
           catch(IOException _ex) { }
        public static Properties getEnvVars(String env_var) throws Throwable {
           Properties envVars = new Properties();
           Process p = Runtime.getRuntime().exec(env_var);
           BufferedReader br = new BufferedReader( new InputStreamReader( p.getInputStream() ) );
           String line = null;
           while( (line = br.readLine()) != null ) {
              int idx = line.indexOf( '=' );
              String key = line.substring( 0, idx );
              String value = line.substring( idx+1 );
              envVars.setProperty( key, value );
              // System.out.println( key + " = " + value );
           return envVars;
        }

    Updated code:
    public static void logMessage(String message) {
           SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss ");
           Date now = new Date();
           Properties p = null;   
           try
              p = getEnvVars("$TMP");
              System.out.println("the current value of TEMP is : " + System.getProperty("$TMP"));
           catch (Throwable e) {
              e.printStackTrace();
           try
           BufferedWriter os = new BufferedWriter(new FileWriter("/tmp/pscas_signon_log.txt", true));
           os.write(formatter.format(now));
           os.write(message);
           os.write("\n");
           os.write("tmp_env = " + System.getProperty("$TMP"));
           os.write("\n");
           os.close();
           catch(IOException _ex) { }
        public static Properties getEnvVars(String env_var) throws Throwable {
           Properties envVars = new Properties();
           Process p = Runtime.getRuntime().exec(env_var);
           BufferedReader br = new BufferedReader( new InputStreamReader( p.getInputStream() ) );
           String line = null;
           while( (line = br.readLine()) != null ) {
              int idx = line.indexOf( '=' );
              String key = line.substring( 0, idx );
              String value = line.substring( idx+1 );
              envVars.setProperty( key, value );
              // System.out.println( key + " = " + value );
           return envVars;
        }and this is the error message..
    java.io.IOException: $TMP: not found
            at java.lang.UNIXProcess.forkAndExec(Native Method)
            at java.lang.UNIXProcess.<init>(UNIXProcess.java:72)
            at java.lang.Runtime.execInternal(Native Method)
            at java.lang.Runtime.exec(Runtime.java:602)
            at java.lang.Runtime.exec(Runtime.java:461)
            at java.lang.Runtime.exec(Runtime.java:397)
            at java.lang.Runtime.exec(Runtime.java:359)
            at SimpleCasValidator.getEnvVars(SimpleCasValidator.java:108)
            at SimpleCasValidator.logMessage(SimpleCasValidator.java:81)

  • Java classpath with Environment variable..

    Hi,
    I need to start an Java application with an Environment variable(EV) as class path.
    Ex:
    I have an EV APP_PATH =c:\myapp
    so i will give java -cp c:\myapp, instead of doing like this I need to give APP_PATH in the java -cp<EV>.
    I gave like this java -cp %APP_PATH% and that doesn't work...
    Is this the correct way or how to do this ?
    Thanks.

    I gave like this java -cp %APP_PATH% and that doesn't
    work...It does if APP_PATH has the correct value.
    Try echo %APP_PATH% and see if it's what you expect. They plug whatever that returns into your java command.
    Is this the correct way or how to do this ?That's the correct way. You APP_PATH must be wrong.

  • How i can set environment variable with java?

    i'm tring to set it using System.setProperty("java.class.path") but it dosen't work any body help?

    you will have to find out the EXACT verbage, but it's
    something like this I suppose:
    Runtime runtime = System.getRuntime();
    runtime.exec("cmd set MY_VAR=blahhhhhhh");Yes... this creates a new process, then sets the MY_VAR environment variable for that process to "blahhhhhhh", then terminates that process.
    However I think you are asking the wrong question, since your post suggests you are trying to change your classpath programatically. Ask the question you thought that was the answer to instead.

  • Update environment variables of unix from java

    i want to update DISPLAY environment variable in unix from java.
    (very urgent).

    Basically not possible. The environmental variables belong to a particular task, typically the shell, and your JVM process just has a copy. If you create another task (with Runtime.exec) you can specify whatever environmental variables you like but it's always the parent that supplies them to the child, not the other way arround. (export is handled internally by the shell's own task, it's not a program of it's own).

  • How to set environment variables using java program

    Hi all
    I want to set environment variables on windows 98/200/xp system, such as path and classpath using a java program.
    How to do this using a java program.
    Any body plz helppppppppp.

    #1 05-02-2003, 07:38 AM
    Goodz13 Join Date: Jan 2002, Posts: 985
    Location: Halifax, NS, Canada
    Reputation:
    Java FAQ's and tutorials
    Java FAQ's
    Path and ClassPath:
    PATH
    In Windows 9x you would set it up in the autoexec.bat file
    ie.
    SET PATH=%PATH%;c:\jdk1.4.2\bin\;
    where c:\jdk1.4.2\ is the path where you installed Java.
    In Windows 2000 and XP
    Right click on My Computer->Properties->Advanced Tab->Environment Variables... Button.
    If you see a PATH in System Variables, click that and edit it. If you don't, you will need to create a new System variable.
    It should look something like this:
    %SystemRoot%\system32;%SystemRoot%;c:\jdk1.4.2\bin\;
    Any querry email me to [email protected]
    Answer by
    Rajasekhar Goli
    DS UNICS Infotech

Maybe you are looking for