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);

Similar Messages

  • Setting persitent system environment variables using java program

    hai,
    Iam tryng to write installation for an application,which require to set some persistent system environment variables using java program. I have tried using set command Runtime.getRuntime().exec("cmd /c set blah blah "),but this applies only to that particular DOS promt only,i presume.And this is not perisistent.please do help.
    Biju

    The solution I proposed worked only on Windows XP/2003.
    The following solution will work on Windows NT/2000/XP/2003 with JDK 1.2+.
    1- Download the [url http://www.gjt.org/download/time/java/jnireg/registry-3.1.3.zip]JNIRegistry zipped archive.
    2- Open the registry-3.1.3.zip file and extract in the folder of your choice ( Eg. c:\setenv ) only the 2 first files (when sorted by path): ICE_JNIRegistry.dll and registry.jar.
    You don't need to keep the folder tree in the extraction.
    3- Create the following SetEnv.java file in the same folder ( Eg. c:\setenv ).
    import com.ice.jni.registry.Registry;
    import com.ice.jni.registry.RegistryKey;
    import com.ice.jni.registry.RegStringValue;
    import com.ice.jni.registry.RegistryValue;
    public class SetEnv
        static final String REG_HKLM_SUBKEY_NAME = "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment";
        public static void main(String[] args)
        throws Exception
            new SetEnv().exec(args);
        void exec(String[] args)
        throws Exception
            if (args.length != 2)
                throw new IllegalArgumentException("\n\nUsage: java SetEnv {varName} {varValue}\n\n");
            String varName = args[0];
            String varValue = args[1];
            RegistryKey key = null;
            RegStringValue value;
            try
                key = Registry.HKEY_LOCAL_MACHINE.openSubKey(REG_HKLM_SUBKEY_NAME, RegistryKey.ACCESS_ALL);
                value = new RegStringValue(key, varName, RegistryValue.REG_EXPAND_SZ);           
                value.setData(varValue);
                key.setValue(value);
                key.flushKey();
            finally
                try { key.closeKey(); }
                catch (Exception e) {}
    }4- Compile it.
    javac -classpath .;registry.jar SetEnv.java
    5- Run it. varName and varValue are strings of your choice.
    java -classpath .;registry.jar -Djava.library.path=. SetEnv varName varValue

  • 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

  • Unable to access values from database in login page..

    Hey all,
    Friends I have a login.jsp page and I want if i enter username and password then it will be accessed from database and after verifying the details it will open main.jsp.I made a database as "abc" and created DSN as 1st_login having table 1st_login. But the problem is that I am unable to access values from database.
    So Please help me.
    Following is my code:
    <HTML>
    <body background="a.jpg">
    <marquee>
                        <CENTER><font size="5" face="times" color="#993300"><b>Welcome to the"<U><I>XYZ</I></U>" of ABC</font></b></CENTER></marquee>
              <br>
              <br>
              <br>
              <br><br>
              <br>
         <form name="login_form">
              <CENTER><font size="4" face="times new roman">
    Username          
              <input name="username" type="text" class="inputbox" alt="username" size="20"  />
              <br>
         <br>
              Password          
              <input type="password" name="pwd" class="inputbox" size="20" alt="password" />
              <br/>
              <input type="hidden" name="option" value="login" />
              <br>
              <input type="SUBMIT" name="SUBMIT" class="button" value="Submit" onClick="return check();"> </CENTER>
              </td>
         </tr>
         <tr>
              <td>
              </form>
              </table>
    <%
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection connection = DriverManager.getConnection("jdbc:odbc:1st_login");
    Statement statement = connection.createStatement();
    String query = "SELECT username, password FROM 1st_login WHERE username='";
    query += request.getParameter("username") + "' AND password='";
    query += request.getParameter("password") + "';";
    ResultSet resSum = statement.executeQuery(query);
    //change: you gotta move the pointer to the first row of the result set.
    resSum.next();
    if (request.getParameter("username").equalsIgnoreCase(resSum.getString("username")) && request.getParameter("password").equalsIgnoreCase(resSum.getString("password")))
    %>
    //now it must connected to next page..
    <%
    else
    %>
    <h2>You better check your username and password!</h2>
    <%
    }catch (SQLException ex ){
    System.err.println( ex);
    }catch (Exception er){
    er.printStackTrace();
    %>
    <input type="hidden" name="op2" value="login" />
         <input type="hidden" name="lang" value="english" />
         <input type="hidden" name="return" value="/" />
         <input type="hidden" name="message" value="0" />
         <br>
              <br><br>
              <br><br>
              <br><br><br><br><br>
              <font size="2" face="arial" color="#993300">
         <p align="center"> <B>ABC &copy; PQR</B>
    </BODY>
    </HTML>
    and in this code i am getting following error
    C:\Project\SRS\build\generated\src\org\apache\jsp\loginjsp.java:93: cannot find symbol_
    C:\Project\SRS\build\generated\src\org\apache\jsp\loginjsp.java:93: cannot find symbol_
    C:\Project\SRS\build\generated\src\org\apache\jsp\loginjsp.java:94: cannot find symbol_
    C:\Project\SRS\build\generated\src\org\apache\jsp\loginjsp.java:95: cannot find symbol_
    4 errors
    C:\Project\SRS\nbproject\build-impl.xml:360: The following error occurred while executing this line:
    C:\Project\SRS\nbproject\build-impl.xml:142: Compile failed; see the compiler error output for details.
    BUILD FAILED (total time: 6 seconds)

    As long as you're unable to compile Java code, please use the 'New to Java' forum. This is really trival.
    To ease writing, debugging and maintenance, I highly recommend you to write Java code in Java classes rather than JSP files. Start learning Servlets.

  • Referencing a system environment variable

    Hi all,
    I am attempting to reference a system environment variable in an OS command within a package. However, it continues to error out with the generic "Wrong process return code" error. For now, I am assuming this is due to my reference to a system variable in the file path.
    Note: when I'm directly on the ODI server and type in the exact same command into a command window, it works fine. It doesn't work when I call it from the generated scenario, via the Operator client on my computer.
    Here is an example of my call line:
    essmsh.exe %SysVarName%\somefile.mxl
    Does anyone know how to reference the system environment variable correctly? Or...is there a better way to accomplish the same task?
    Thanks!
    -OS

    Thank you for your response, Ankit!
    Yes, essmsh.exe must be visible to the agent, because if I replace the reference to the system variables with hard-coded values, the scenario executes with no error.
    I am not familiar with Jython procedures, and I am hesitant to create any as the there is no one on the team who can support them. Is there no direct reference one can use directly from the package/scenario? It seems odd that there is no current way to handle this, but perhaps I am naive.

  • Windows System Environment Variables in "Sql * plus"

    Can i use/reference Windows System Environment variables in "Sql * plus"?
    For example, i want to create sql-script to run in database server computer that asks variable "ORA_HOME" and uses this value to execute some sql/plsql sentences.
    Oracle 10g Personal, Windows 7.
    Edited by: CharlesRoos on 12.11.2010 17:28

    CharlesRoos wrote:
    Business problem:
    I have created 2 databases in my computer. Both databases needs tablespaces created by a script. Tablespaces' datafiles (.dbf files) names are same for both database. Both database has it's own directory where it holds datafiles at the moment. At the moment the datafiles for Database1 are in folder something like "%ORACLE_HOME%"\oradata\%databasename1%\*.dbf, and second database has its datafiles in other folder, somewhere ""%ORACLE_HOME%"\oradata\%databasename1%\*.dbf". I want now the script to create tablespace called "INDX" with same datafile name "indx1.dbf" into both database. So into both mentioned folder the file "indx1.dbf" must be created by script. I think the script should do following:
    1. get ORACLE_HOME.
    2. connect to database "databasename1"
    3. EXECUTE IMMEDIATE "Create TableSpace INDX....file=%ORACLE_HOME% || databasename1 || indx1.dbf"
    4. connect to database "databasename2"
    5. EXECUTE IMMEDIATE "Create TableSpace INDX....file=%ORACLE_HOME% || databasename2 || indx1.dbf"I don't have Oracle database near by anymore, so the code was pseudocode.
    I don't understand how to use ?-shortcut.OK, my first impression is "why does this even NEED to be scripted? Creation of new tablespaces is usually a one-off operation.
    But that aside how about this sqlplus command-line substitution variables. This example is in linux, but will work as well in Windows with the change of the way environment variables are referenced:
    *nix - echo $myvariable
    Windows - echo %myvariable%
    First, the sqlscript to create the TS. Note the use of the substitution variable "&1"
    {code}
    [oracle@vmlnx01 ~]$ cat cat makets.sql
    set echo on feedback on verify on trimsp on
    prompt &1
    CREATE SMALLFILE TABLESPACE EDSTEST
    DATAFILE '/ora01/oradata/&1/edstest.dbf'
    SIZE 5M
    REUSE
    AUTOEXTEND ON
    NEXT 1280K
    MAXSIZE 32767M
    LOGGING
    EXTENT MANAGEMENT LOCAL
    SEGMENT SPACE MANAGEMENT AUTO
    drop tablespace edstest
    including contents and datafiles
    exit
    {code}
    So, at the OS prompt: Notice that the @ is separated by a space, makeing it a command line parm instead of part of the connect string
    {code}
    [oracle@vmlnx01 ~]$ export myparm=vlnxora1
    [oracle@vmlnx01 ~]$ sqlplus system/pswd @makets $myparm
    SQL*Plus: Release 10.2.0.4.0 - Production on Fri Nov 12 13:18:05 2010
    Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> prompt &1
    vlnxora1
    SQL> --
    SQL> CREATE SMALLFILE TABLESPACE EDSTEST
    2 DATAFILE '/ora01/oradata/&1/edstest.dbf'
    3 SIZE 5M
    4 REUSE
    5 AUTOEXTEND ON
    6 NEXT 1280K
    7 MAXSIZE 32767M
    8 LOGGING
    9 EXTENT MANAGEMENT LOCAL
    10 SEGMENT SPACE MANAGEMENT AUTO
    11 ;
    old 2: DATAFILE '/ora01/oradata/&1/edstest.dbf'
    new 2: DATAFILE '/ora01/oradata/vlnxora1/edstest.dbf'
    Tablespace created.
    SQL> --
    SQL> drop tablespace edstest
    2 including contents and datafiles
    3 ;
    Tablespace dropped.
    SQL> exit
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    [oracle@vmlnx01 ~]$
    {code}

  • How to get system Environment variable?

    How to get system Environment variable without using jni?
    just like "JAVA_HOME" or "PATH"...
    Any reply is help to me!! :-)

    Thx for your reply...
    I get it!!!
    Read environment variables from an application
    Start the JVM with the "-D" switch to pass properties to the application and read them with the System.getProperty() method. SET myvar=Hello world
    SET myothervar=nothing
    java -Dmyvar="%myvar%" -Dmyothervar="%myothervar%" myClass
    then in myClass String myvar = System.getProperty("myvar");
    String myothervar = System.getProperty("myothervar");
    This is useful when using a JAVA program as a CGI.
    (DOS bat file acting as a CGI) java -DREQUEST_METHOD="%REQUEST_METHOD%"
    -DQUERY_STRING="%QUERY_STRING%"
    javaCGI
    If you don't know in advance, the name of the variable to be passed to the JVM, then there is no 100% Java way to retrieve them.
    NOTE: JDK1.5 provides a way to achieve this, see this HowTo.
    One approach (not the easiest one), is to use a JNI call to fetch the variables, see this HowTo.
    A more low-tech way, is to launch the appropriate call to the operating system and capture the output. The following snippet puts all environment variables in a Properties class and display the value the TEMP variable. import java.io.*;
    import java.util.*;
    public class ReadEnv {
    public static Properties getEnvVars() throws Throwable {
    Process p = null;
    Properties envVars = new Properties();
    Runtime r = Runtime.getRuntime();
    String OS = System.getProperty("os.name").toLowerCase();
    // System.out.println(OS);
    if (OS.indexOf("windows 9") > -1) {
    p = r.exec( "command.com /c set" );
    else if ( (OS.indexOf("nt") > -1)
    || (OS.indexOf("windows 2000") > -1 )
    || (OS.indexOf("windows xp") > -1) ) {
    // thanks to JuanFran for the xp fix!
    p = r.exec( "cmd.exe /c set" );
    else {
    // our last hope, we assume Unix (thanks to H. Ware for the fix)
    p = r.exec( "env" );
    BufferedReader br = new BufferedReader
    ( new InputStreamReader( p.getInputStream() ) );
    String line;
    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;
    public static void main(String args[]) {
    try {
    Properties p = ReadEnv.getEnvVars();
    System.out.println("the current value of TEMP is : " +
    p.getProperty("TEMP"));
    catch (Throwable e) {
    e.printStackTrace();
    Thanks to W.Rijnders for the W2K fix.
    An update from Van Ly :
    I found that, on Windows 2003 server, the property value for "os.name" is actually "windows 2003." So either that has to be added to the bunch of tests or just relax the comparison strings a bit: else if ( (OS.indexOf("nt") > -1)
    || (OS.indexOf("windows 2000") > -1 )
    || (OS.indexOf("windows 2003") > -1 ) // works but is quite specific to 2003
    || (OS.indexOf("windows xp") > -1) ) {
    else if ( (OS.indexOf("nt") > -1)
    || (OS.indexOf("windows 20") > -1 ) // probably is better since no other OS would return "windows" anyway
    || (OS.indexOf("windows xp") > -1) ) {
    I started with "windows 200" but thought "what the hell" and made it "windows 20" to lengthen its longivity. You could push it further and use "windows 2," I suppose. The only thing to watch out for is to not overlap with "windows 9."
    On Windows, pre-JDK 1.2 JVM has trouble reading the Output stream directly from the SET command, it never returns. Here 2 ways to bypass this behaviour.
    First, instead of calling directly the SET command, we use a BAT file, after the SET command we print a known string. Then, in Java, when we read this known string, we exit from loop. [env.bat]
    @set
    @echo **end
    [java]
    if (OS.indexOf("windows") > -1) {
    p = r.exec( "env.bat" );
    while( (line = br.readLine()) != null ) {
    if (line.indexOf("**end")>-1) break;
    int idx = line.indexOf( '=' );
    String key = line.substring( 0, idx );
    String value = line.substring( idx+1 );
    hash.put( key, value );
    System.out.println( key + " = " + value );
    The other solution is to send the result of the SET command to file and then read the file from Java. ...
    if (OS.indexOf("windows 9") > -1) {
    p = r.exec( "command.com /c set > envvar.txt" );
    else if ( (OS.indexOf("nt") > -1)
    || (OS.indexOf("windows 2000") > -1
    || (OS.indexOf("windows xp") > -1) ) {
    // thanks to JuanFran for the xp fix!
    p = r.exec( "cmd.exe /c set > envvar.txt" );
    // then read back the file
    Properties p = new Properties();
    p.load(new FileInputStream("envvar.txt"));
    Thanks to JP Daviau
    // UNIX
    public Properties getEnvironment() throws java.io.IOException {
    Properties env = new Properties();
    env.load(Runtime.getRuntime().exec("env").getInputStream());
    return env;
    Properties env = getEnvironment();
    String myEnvVar = env.get("MYENV_VAR");
    To read only one variable : // NT version , adaptation for other OS is left as an exercise...
    Process p = Runtime.getRuntime().exec("cmd.exe /c echo %MYVAR%");
    BufferedReader br = new BufferedReader
    ( new InputStreamReader( p.getInputStream() ) );
    String myvar = br.readLine();
    System.out.println(myvar);
    Java's System properties contains some useful informations about the environment, for example, the TEMP and PATH environment variables (on Windows). public class ShowSome {
    public static void main(String args[]){
    System.out.println("TEMP : " + System.getProperty("java.io.tmpdir"));
    System.out.println("PATH : " + System.getProperty("java.library.path"));
    System.out.println("CLASSPATH : " + System.getProperty("java.class.path"));
    System.out.println("SYSTEM DIR : " +
    System.getProperty("user.home")); // ex. c:\windows on Win9x system
    System.out.println("CURRENT DIR: " + System.getProperty("user.dir"));
    Here some tips from H. Ware about the PATH on different OS.
    PATH is not quite the same as library path. In unixes, they are completely different---the libraries typically have their own directories. System.out.println("the current value of PATH is: {" +
    p.getProperty("PATH")+"}");
    System.out.println("LIBPATH: {" +
    System.getProperty("java.library.path")+"}");
    gives the current value of PATH is:
    {/home/hware/bin:/usr/local/bin:/usr/xpg4/bin:/opt/SUNWspro/bin:/usr/ccs/bin:
    /usr/ucb:/bin:/usr/bin:/home/hware/linux-bin:/usr/openwin/bin/:/usr/games/:
    /usr/local/games:/usr/ccs/lib/:/usr/new:/usr/sbin/:/sbin/:/usr/hosts/:
    /usr/openwin/lib:/usr/X11/bin:/usr/bin/X11/:/usr/local/bin/X11:
    /usr/bin/pbmplus:/usr/etc/:/usr/dt/bin/:/usr/lib:/usr/lib/lp/postscript:
    /usr/lib/nis:/usr/share/bin:/usr/share/bin/X11:
    /home/hware/work/cdk/main/cdk/../bin:/home/hware/work/cdk/main/cdk/bin:.}
    LIBPATH:
    {/usr/lib/j2re1.3/lib/i386:/usr/lib/j2re1.3/lib/i386/native_threads:
    /usr/lib/j2re1.3/lib/i386/client:/usr/lib/j2sdk1.3/lib/i386:/usr/lib:/lib}
    on my linux workstation. (java added all those execpt /lib and /usr/lib). But these two lines aren't the same on window either:
    This system is windows nt the current value of PATH is:
    {d:\OrbixWeb3.2\bin;D:\jdk1.3\bin;c:\depot\cdk\main\cdk\bin;c:\depot\
    cdk\main\cdk\..\bin;d:\OrbixWeb3.2\bin;D:\Program
    Files\IBM\GSK\lib;H:\pvcs65\VM\win32\bin;c:\cygnus
    \cygwin-b20\H-i586-cygwin32\bin;d:\cfn\bin;D:\orant\bin;C:\WINNT\system32;C:\WINNT;
    C:\Program Files\Dell\OpenManage\Resolution Assistant\Common\bin;
    d:\Program Files\Symantec\pcAnywhere;
    C:\Program Files\Executive Software\DiskeeperServer\;C:\Program Files\Perforce}
    LIBPATH:
    {D:\jdk1.3\bin;.;C:\WINNT\System32;C:\WINNT;d:\OrbixWeb3.2\bin;D:\jdk1.3\bin;
    c:\depot\cdk\main\cdk\bin;c:\depot\cdk\main\cdk\..\bin;
    d:\OrbixWeb3.2\bin;D:\Program Files\IBM\GSK\lib;
    H:\pvcs65\VM\win32\bin;c:\cygnus\cygwin-b20\H-i586-cygwin32\bin;d:\cfn\bin;
    D:\orant\bin;C:\WINNT\system32;
    C:\WINNT;C:\Program Files\Dell\OpenManage\ResolutionAssistant\Common\bin;
    d:\Program Files\Symantec\pcAnywhere;
    C:\Program Files\Executive Software\DiskeeperServer\;C:\Program Files\Perforce}

  • Reading Operationg System Environment Variables

    How can i read Operating System environment variables for examples in Windows without using java -D option
    just to simply get the value from windows enviroment variables settings... such as "MyApp"
    is there a way i can get the value using java???
    need something that is backward compatible ... like between jdk version 1.2.2 to 1.3.1???
    help...
    :~(
    Thanks in Advance,
    Cheah

    Some ugly hack like using Runtime.getRuntime().exec("echo %wasteoftime%") and examining its output might work.

  • Which Oracle folders into "PATH" system Environment Variable

    Which Oracle folders must exist into "PATH" system Environment Variable in Windows OS?
    The folders must contain Oracle command line utilities, like "sql * plus", "exp" and so on.

    The path to your bin folder ...
    for eg :
    D:\oracle\product\10.2.0\db_1\bin;Cheers :)
    Renjith Madhavan

  • How to manipulate Windows System Variables using Java

    Hi There,
    I want to manipulate Windows System variables (e.g. PATH, CLASSPATH) using Java program. Could anyone please let me know how it can be done in Java.
    Regards,
    Rakesh Nagar

    This is not just a Java question. It has never been possible in any Windows program to permanently change the value of an environment variable. You can only change it temporarily, and when the process that changed it ends, so does the change to the environment variable. This has been true since environment variables were added to DOS in about 1983.

  • How can i get system variable using java

    Hi,
    I just want to know how can i get system variables using java code.
    for example i want to get the the date for today or i want to get the number of processes that's running.
    Thanks alot

    Hi,
    I just want to know how can i get system variables
    using java code.
    for example i want to get the the date for today or i
    want to get the number of processes that's running.
    Thanks alotSome generic "system variables" are available though Java, usually through the System class.
    Date today = new Date();
    is instantiated with the current date and time.
    Other system values, like environment values, should be passed to java through the command line (-D option) by setting system properties.
    Finally, platform specific values like the number of processes running will have to be written in platform specific code and executed by JNI (java native interface).
    Java is platform or system agnostic. Common system values, like time, are implemented. Hopefully you won't need platform specific values.

  • Setting windows environment variables from Java program

    Is there any way to set environment variables from Java program in Windows? Any help is appreciated.
    Here is my situation:
    I need to decrypt an encrypted Oracle user password in a batch file which will be used while running a sql script with sqlplus. I was planning to have bat file which will call a Java program decrypt the password and set it as an env variable in windows which will be available while calling sqlplus.
    thanks

    Runtime.exec has a lot of overloadings. Two of them
    allows you to specify the environment variables.
    exec
    public Process exec(String[] cmdarray,
    String[] envp,
    File dir)
    throws IOExceptionExecutes the specified command and
    arguments in a separate process with the specified
    environment and working directory.
    cmdarray - array containing the command to call and
    its arguments.
    envp - array of strings, each element of which has
    environment variable settings in format name=value.
    dir - the working directory of the subprocess, or null
    if the subprocess should inherit the working directory
    of the current process.
    I had this sample program:
    public class SetVarExample {
    public static void main (String[] args) throws Exception {
         String[] cmd_env= new String[] {"password="+"ABCD","Path=C:\\Sun\\AppServer\\jdk\\bin"};
         String cmd = "cmd /c SET ";
         Runtime.getRuntime().exec(cmd,cmd_env);
    System.out.println( "Finish ...." );
    I tried it in a command prompt. But looks like when the program exits, it's a whole new process and so it does not retain the env variables set in the java program.
    Any suggestions? Am I doing it worng?
    thanks

  • Best practice for setting an environment variable used during NW AS startup

    We have installed some code which is running in both the ABAP and JAVA environment, and some functionality of this code is determined by the setting of operating system environment variables. We have therefore changed the .sapenv_<host>.csh and .sapenv_<host>.sh scripts found in the <sid>adm user home directory. This works, but we are wondering what happens when SAP is upgraded, and if these custom shell script changes to the .sh and .csh scripts will be overwritten during such an upgrade. Is there a better way to set environment variables so they can be used by the SAP server software when it has been started from <sid>adm user ?

    Hi,
    Thankyou. I was concerned that if I did that there might be a case where the .profile is not used, e.g. when a non-interactive process is started I was not sure if .profile is used.
    What do you mean with non-interactive?
    If you login to your machine as sidadm the profile is invoked using one of the files you meant. So when you start your Engine the Environment is property set. If another process is spawned or forked from a running process it inherits / uses the same Environment.
    Also, on one of my servers I have a .profile a .login and also a .cshrc file. Do I need to update all of these ?
    the .profile is used by bash and ksh
    The .cshrc is used by csh and it is included via source on every Shell Startup if not invoked with the -f Flag
    the .login is also used by csh and it is included via source from the .cshrc
    So if you want to support all shells you should update the .profile (bash and ksh) and one of .cshrc or .login for csh or tcsh
    In my /etc/passwd the <sid>adm user is configured with /bin/csh shell, so I think this means my .cshrc will be used and not the .profile ? Is this correct ?
    Yes correct, as described above!
    Hope this helps
    Cheers

  • ICloud backup is unable to access the account, because email I used for iCloud account is been deleted. And my iPad is stuck with this note on a screen, can't go Settings. How do I delete my account?

    iCloud backup is unable to access my account, because email I used for iCloud account is been deleted. And my iPad is stuck with this note on a screen, can't go Settings. How do I delete or edit my iCloud account?

    You can eirther I think go on ITunes or if you can get to settings you would just go to iCloud.

  • How to set a value to a Presentation Variable using GO URL?

    Hi All,
         I am working on a drill (GO URL) from Dashboard page1 to Dashboard page2.
         The problem I am facing is, I am not able to pass a value to the presentation variable through GO URL. (I have to pass "Customer Category" static
    value to The presentation variable present in Dashboard Page2 ).
         The Dashboard page2 is having a view select in which we are using presentation variable to select the report based on the value selected in
    View Select.
         For example: If the user selects "Customer Category" value in View select and clicks on GO button Customer Category report will show the out put.
         When i am drilling from Dashboard Page1 I have to pass a value to the presentation variable used in view select and also pass some filter condition in
         GO URL.
         Please let me know if it is feasible to pass a value to the presentation variable through GO URL in OBIEE 10.1.3.4.
         It will be greate if you can provide me with the syntax to set a value to the presentation variable of dashboard page2 through GO URL.
    Thanks and Regards,
    Sagar Vishwanathwar.

    1) You have to navigate to dashboard page, not to answer request = you have to use "Dashboard URL API" not GO URL API.
    2) On the target page, you have to place dashboard prompt, which sets required presentation variable.
    3) Refer to the target using Dashboard URL API and set filter on prompt column using URL parameters. Example: http://localhost:9704/analytics/saw.dll?Dashboard&PortalPath=%2Fusers%2Fadministrator%2F_portal&Page=page%201&Action=Navigate&P0=1&P1=eq&P2=D_TIME.YEAR_CODE&P3=%221996%22
    Do not forget to use Action=Navigate. The syntax for setting filters using url parameter is the same as for GO URL API described in Business Intelligence Presentation Services Administration Guide.
    This is the way, you can implement navigation to parametrized direct SQL reports including passing filter values...
    Regards K.

Maybe you are looking for

  • Ipod shuffle is not recognized by any computer or itunes

    I have a first gen. ipod shuffle. It does not show up in Windows or Itunes on two different computers. The original problem was that it would not skip to the next song. I was going to reset or restore it, but I can't because neither computer (dell) t

  • Weird error message when trying to use migration assistant?

    We gave my mom a Macbook Pro for Mother's Day. While trying to set it up for her using migration assistant pc to mac, her Dell kept coming up with an error message saying msidcrl40.dll is missing?? What the heck does that even mean? Needless to say m

  • Local Host Forbidden PHP

    Hi, I have enabled PHP, but removing # from LoadModule php5_module. I have also enabled Web sharing. When i go on to http://localhost/, i get the normal confirmation page that Apache was installed correctly. However when i few files in other director

  • GUI Tool for Image Analysis (delimited ascii file)

    i've created a Java GUI Tool for Image Analysis. It does length calculation and locate the coordinate of centroid of an image...the problem now is how do i save the results in a delimited ascii file??

  • Xcode no longer free?

    I tried to download Xcode today, and was told 'access denied'. (I only have the free ADC subscription level.) Looks like there's a new mac developer program, along the lines of the iOS developer program, that requires a $99 tax. Has Apple decided to