ProcessBuilder and Environment variables

There is any way to use environment variables, like in dos, with %% through java programming?
For example :
ProcessBuilder pb = new ProcessBuilder("c:/winnt/notepad.exe", "%TTT%");
// Would be even better :) ... But the previous line is Ok ;)
// ProcessBuilder pb = new ProcessBuilder("c:/winnt/notepad.exe %TTT%");
Map<String,String> env = pb.environment();
env.put("TTT", "M:/temp/testTTT.txt");
try{
Process process = pb.start();
catch(Exception e){
e.printStackTrace();
}

Cool, it worked, Thanks sabre150 :)
The strange thing is that with echo works, with dir no!!! :)
//     String[] command = { "cmd.exe", "/C", "echo %TTT%", };
     String[] command = { "cmd.exe", "/C", "dir %TTT%", };
final ProcessBuilder pb = new ProcessBuilder(command);
Map<String,String> env = pb.environment();
env.put("TTT", "M:/temp");
try{
Process process = pb.start();
InputStream is = process.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line;
while ((line = br.readLine()) != null) {
System.out.println(line);
catch(Exception e){
e.printStackTrace();
}

Similar Messages

  • Open module for managing property file and environment variables

    Looking for an open module for managing property files and environment variables (like CLASSPATH) set in a shell script. For handeling properties (preserving comments, supporting includes, appending new entries, and more) I have looked at SuperProperties from openadaptor but find certain functionality lacking. As for interfacing with common shell scripts/files containing setting for CLASSPATH, JAVA_HOME, other system/application variables another type of object editor is needed. Maybe JFIG?
    Any ideas are greatly welcomed.

    You seem wright, you hit a brick wall here with Air to find the location
    of the command console on windows...
    So in fact I never build an exe tool, but this little problem was a nice
    case to test it and I tried it.:
    I downloaded monodevelop
    -GTK# for .NET 2.12.10*
    -MonoDevelop 2.4.2*
       from http://monodevelop.com/Download
    created a console project and had an exe in 5 minutes !
    You can download the findconsole tool and the projectfiles here:
       http://greencollective.nl/temp/dump/findconsole_monoproject.zip
    findconsole.exe will reveal the path/location of cmd.exe on a windows system.
    Cheers,
    Latcho

  • Library paths and environment variables

    Hello,
    I am using 10g AS 9.0.4 on a Unix system.
    I am trying to convert an old JSP web application to work with 10g. It is not an EAR/WAR file so I am manually trying to set it up under the "default-web-app" folder. It uses a number of java class files which currently reside in $J2EE_HOME/default-web-app/WEB-INF/classes/mystuff.
    These class files require access to a number of libraries. I foolishly believed that they would be accessible if I were to place them in the $J2EE_HOME/default-web-app/WEB-INF/lib folder, but that did not work.
    I read that OC4J uses a "catch all" lib directory at $J2EE_HOME/applib. I copied the library files there and they still did not work.
    Frustrated, I tried to print out the environment variables for the server - only to find that this function is not supported.
    I managed to print out the library path by creating a Java class files which returns the following as a string:
    System.getProperty("java.library.path");
    This (when called from a JSP) prints a number of different library paths, none of which match those found listed in the $J2EE_HOME/config/application.xml file. I placed the library files in one of the paths listed by the "java.library.path" and it worked!
    3 questions:
    1. How do you print the server's environment variables using a JSP? This strikes me as a very useful function for sorting out library and path issues. Do a search on Google for "print environment variables OC4J" or something similar and there are no useful pages suggesting how this can be done.
    2. Why are the default library paths different on the server than to those specified in application.xml?
    3. How do I change the LD_LIBRARY_PATH (or any environment variable for that matter)? I have tried adding the following line to $ORACLE_HOME/Apache/Jserv/etc/jserv.properties without success:
    wrapper.env=LD_LIBRARY_PATH=/my/custom/library/path
    Any help you can offer would be most appreciated.

    >
    Thanks very much for a such a comprehensive response
    - it has helped answer a lot of questions, especially
    being able to print out the system properties. That
    will be really useful!
    No worries at all Rob.
    The main hurdle is that the libraries are indeed
    native (*.so) libraries. I hadn't considered that
    until you pointed it out in your message. Can I
    assume, then, that $J2EE_HOME/applib and
    $J2EE_HOME/default-web-app/WEB-INF/lib are only
    designed to handle Java's .JAR librares? That would
    explain why placing the native libraries in there
    didn't work, but is there a way of getting such
    native libraries recognised and bundled up in a
    WAR/EAR file?
    Yep, that's it.
    Our proprietary applib and the servlet specs web-inf/lib are only dealing with Java archives.
    The J2EE specs don't cover how to deal with native libs like this.
    Now I've NEVER EVER tried it, but it's worth a shot of at least trying -- for simplified packaging purposes, what you may be able to do is to distribute the .so's within the web-inf/lib -- and then just set that directory (where's its realized on the server after the app is deployed) to be referenced witihn the LD_LIBRARY_PATH. I'd expect our deployment manager will just ignore files it doesn't know about, so arguably you should be able to at least distribute them with the standard archive.
    You'll need to specifically set the LD_LIBRARY_PATH as a separate task outside of the deployment operation though.
    >
    This is where things get a bit weird, and is partly
    my fault during the installation of 10g AS.
    We already had an existing installation of Oracle 10g
    Database (10.1.0) at $ORACLE_HOME under the user
    "oracle". I logged in as the user "oracle" to install
    the Application Server into a different location (In
    this case, "$ORACLE_HOME/../ias10g_9.0.4" - let's
    call this $IAS_HOME). So there is no separate user
    account for Oracle Database and Application Server
    (and hence no separate $LD_LIBRARY_PATH).
    If I log into UNIX as the user "oracle" and echo the
    LD_LIBRARY_PATH, I get the following directories:
    $ORACLE_HOME/lib
    /usr/openv/netbackup/bin
    /usr/dt/lib
    /usr/lib
    I use this user to do "opmnctl stopall" and "opmnctl
    startall". If I then print out the library path from
    a JSP using
    "System.getProperty("java.library.path");", I get the
    following paths:
    $IAS_HOME/jdk/jre/lib/sparc/server
    $IAS_HOME/jdk/jre/lib/sparc
    $IAS_HOME/jdk/jre/../lib/sparc
    $IAS_HOME/opmn/lib
    $IAS_HOME/lib
    $IAS_HOME/usr/lib
    Which is totally different to those listed by
    $LD_LIBRARY_PATH at the command line, which means
    they must be coming from somewhere else.
    It gets worse - my application is trying to call a
    native library that is only present in the
    $ORACLE_HOME/lib32 directory (libclntsh.so.10.1), so
    unless I can include this path in the
    "java.library.path" on the Applicaiton Server, then
    my program will not work.
    So, how do I change the "java.library.path" when the
    values aren't coming from $LD_LIBRARY_PATH in the
    first place?
    The utility $IAS_HOME/opmn/bin/opmnctl is actually a shell script.
    It has this section which sets the LD_LIBRARY_PATH:
    if [ -z "$LD_LIBRARY_PATH" ]
    then
    LD_LIBRARY_PATH=$ORACLE_HOME/opmn/lib:$ORACLE_HOME/lib ; export LD_LIBRARY_PATH
    else LD_LIBRARY_PATH=$ORACLE_HOME/opmn/lib:$ORACLE_HOME/lib:${LD_LIBRARY_PATH} ; export LD_LIBRARY_PATH
    fi
    So if you have an existing LD_LIBRARY_PATH env var set, it should just be putting its paths onto the front of it.
    What you could try as a quick test is to edit the opmnctl script (after taking a backup of course) and either appending the path you need to it, or just add some debug statements to output the LD_LIBRARY_PATH value it ends up setting so you can try and work out what's causing it.
    I expect these other entries:
    $IAS_HOME/jdk/jre/lib/sparc/server
    $IAS_HOME/jdk/jre/lib/sparc
    $IAS_HOME/jdk/jre/../lib/sparc
    are coming from the JRE when it is launched, in probably a similar manner to our opmn entries.
    I really appreciate your help, and I bet if anyone
    can answer these questions, you can! ;-)
    You're very welcome.
    cheers
    -steve-

  • Load Plan logging and environment variables

    Hi all.
    Do think it is possible to log in an external table each load plan step details (such as step name, step duration, etc..) ?
    I'm wondering if there are some environment variables that contain all typical step information.
    Thanks

    thank you for the answer..
    but why I have to use a when case step?
    I just need to set a string in a variable before to execute a serial step within exception step.
    I do this in a normal load plan step. So Why I cannot do the same in the exception one ?

  • Install j2se plugin version 1.6.0_07 on your client and NPX_PLUGIN_PATH environment variable set before starting Netscape.

    Hi experts m new to apps please help.. I have installed successfully Oracle Apps R12 on OEL - 5 All the services runining fine. but when i am opening forms its giving error "install missing plugins" i installed jre-6u7-linux-i586-rpm.bin and Mozilla Firefox 3.0.18 [root@ust ~]# cd firefox/plugins/ [root@ust plugins]# ln -s /usr/java/jre1.6.0_07/plugin/i386/ns7/libjavaplugin_oji.so ./libjavaplugin_oji.so [root@ust plugins]# ls libjavaplugin_oji.so  libnullplugin.so [root@ust plugins]# ll total 20 lrwxrwxrwx 1 root root    58 Sep 11 16:22 libjavaplugin_oji.so -> /usr/java/jre1.6.0_07/plugin/i386/ns7/libjavaplugin_oji.so   -rwxr-xr-x 1 root root 19160 Sep 15  2007 libnullplugin.so [root@ust plugins]# but when m trying to open forms at that time giving error "install j2se plugin version 1.6.0_07 on your client and NPX_PLUGIN_PATH environment variable set before starting Netscape."

    Linux is not a certified client tier for accessing EBS
    Unable to access r12 forms in linux client
    https://forums.oracle.com/search.jspa?view=content&resultTypes=&dateRange=all&q=linux+client&rankBy=relevance&contentTyp…
    HTH
    Srini

  • How to Specify the environment variable JCE_POLICY_ZIP and restart

    Hello All,
    I am installing the ABAP SAP NetWeaver 7.01 SR1 ABAP Trial Version.
    sapinst.exe installed successfully.
    I am installing the sapinstgui.exe but I got the following message:
    Program is starting... Please wait!
      Path: C:\Users\George\AppData\Local\Temp\sapinst_exe.6220.1246290325
    jre\bin\java.exe
    For the requested processing mode java policy
    files within the used SAP JVM are needed.
    Specify the environment variable JCE_POLICY_ZIP and restart.
    See also SAP note 1238121.
    Exit status of child: 10
    JRE is installed in C:\Program Files\Java\j2re1.4.2_19
    How do I specify the environment variable JCE_POLICY_ZIP?
    Thanks
    George
    Edited by: George King on Jun 29, 2009 9:01 PM

    Hi everyone,
    I had the same problem and found the solution !
    I was trying to setup the GUI thanks to sapinstgui.exe from the trial download folder and I got the exact same message,
    The problem is not the policies but the installation file.
    The installation file for the GUI is located at :
    <extract_folder_SAP_trial_version>\GUI\SAP_GUI_FOR_WINDOWS(...)\SAP_GUI_for_windows_(...)_Components.exe
    Hope it helps !
    Nicolas

  • Usage of CGI environment variables SERVER_NAME and HTTP_HOST by APEX

    Hi,
    I have a question about the usage of the CGI environment variables SERVER_NAME/SERVER_PORT and HTTP_HOST by APEX.
    When does it use which CGI environment variables when it is generating absolute URLs.
    Based on the following thread about the online help (Re: Help does not show content it seems to use SERVER_NAME/SERVER_PORT. At least for the online help.
    But based on my own tests some time ago about the flash charting at the following thread (Re: APEX Charts - Error XML Loading falied I investigated that at least flash charting is using HTTP_HOST to generate an absolute URL.
    My question now is what is the logical difference between HTTP_HOST and SERVER_NAME and which of the URLs should be used when I want to generate absolute URLs in my application?
    I would tend to use HTTP_HOST because it seems to be more logically. I would see SERVER_NAME more as just the name of the web-server, which doesn't have to be the URL the user enters in case a reverse proxy is used.
    Thanks
    Patrick
    My APEX Blog: http://inside-apex.blogspot.com
    The ApexLib Framework: http://apexlib.sourceforge.net
    The APEX Builder Plugin: http://sourceforge.net/projects/apexplugin/

    We use HTTP_HOST in most cases from what I can see. You may have also noted that HTTP_HOST may have :<port> appended to the hostname as well.
    Scott

  • Gcc seems not to be recognising environment variables for include and lib.

    I'm trying to install programs into a non standard location, but GCC does not seem to be checking the paths defined in global profile. All 3rd party dependencies are not found and only the default locations are checked.
    The environment variables defined in profile are:
    CPLUSINCLUDEPATH="/DVL/include:/GNU/include:/usr/X11/include:/TEST/include"
    DYLDLIBRARYPATH="/DVL/lib":/GNU/lib:/usr/x11/lib"
    LIBRARY_PATH="/dvl/lib:/gnu/lib:/TEST/lib"
    As GCC is a proven technology, I can only assume that my variables are incorrect or something is missing. Has anyone else experienced this or is your configuration recognising non-standard locations?

    sorry, wrong forum. I put this topic again in forum "portal applications"

  • Multiple oracle homes on Windows and the "Path" environment variable

    Hi There,
    We have a windows 2003 database server that has few databases running oracle 10.2.0.3. We are installing oracle 11.2.0.1 on the box as well, and we were wondering, which binaries should come 1st in the path environment variable? and how does this effect the working oracle environment?
    Going to the oracle home selector and swapping the 2 oracle homes around will have the same effect on the windows path variable - which will treat the 1st oracle home to be the default home - are there any general rules reg. multiple oracle homes on a server and the default home?
    Should the earlier version of oracle always proceed the newer one (i.e. c:\oracle\product\10.2.0.3\bin;c:\oracle\product\11.2.0.1\bin) or should the newer oracle version comes 1st as newer oracle versions are usually backward compatible?
    Your thoughts are highly appreciated.
    Thanks

    That isn't going to happen.
    If you install 11.2 last it will appear in the PATH variable first
    If you don't want that you need to Oracle Home Selector utility in the Installer to change it.
    Obviously, as usual, all of this is documented.
    Sybrand Bakker
    Senior Oracle DBA

  • Simple question about environment variables and setting the class path???

    ok I have been trying for a few months now ontrying to set the class path..
    I work with windows vista..
    on the environment variables user variables,
    I have the name of the variable as class
    and the value as C:\Program Files\Java\jdk1.6.0_04\bin;.
    where javac is...
    on the system variables I have
    its name as class
    and the value as C:\Program Files\Java\jdk1.6.0_04\bin;.
    why is this not reading javac

    The PATH environment variable should have as an entry the directory containing your javac executable. The CLASSPATH should have have entries which define your library directories and entries which are your jar file libraries. In the early days, probably the only CLATHPATH entry you will need will be a '.' to indicate the current directory.
    The Java tutorial covers ALL of this.

  • Environment variable PATH and Sql*Plus

    Hi all,
    i have a problem with sqlplus.
    It might seem not to be able to read the path environment variable.
    I need to launch some sqls without typing their path (to put the path i should modify morre than 300 shell scripts), e.g.: @script.sql.
    My shell scripts are invoked by the database using java.
    Inside the shell scripts we have commands like "sqlplus -silent <login> @script.sql [parameters]"
    So if sqlplus is not able to read the PATH environment variable, the command hangs waiting for something to do without the chance to close it.(it is silent).
    I run RDBMS v8.1.7 on compaq tru64 Unix.
    Can someone help me??
    Thanks in advance.
    Marco - Milan, Italy

    Where do I set SQL*Plus SQLPATH variable??As every other unix environment variable - either in your profile or in your current shell whatever you like
    Is this the PATH where SQL*Plus searches for .sql
    files??SQL*Plus searches for your files in your current directory, and then the directories you specify with the SQLPATH environment variable.
    SQL*Plus searches this colon-separated list of directories in the order they are listed.

  • R12, Environment Variables on Windows, and OBIEE

    Dear Experts,
    I've managed to install R12 on Windows.
    Now, in the global environment variable, Path, the user Oracle has a number of directories in its default PATH, starting with the Oracle apps middle tier.
    C:\oapps\apps\tech_st\10.1.2\bin;     
    C:\oapps\apps\tech_st\10.1.2\jdk\jre\bin\classic;     
    C:\oapps\apps\tech_st\10.1.2\jdk\jre\bin;
    C:\oapps\apps\tech_st\10.1.2\jlib;     
    C:\oapps\apps\tech_st\10.1.3\bin;     
    C:\oapps\db\tech_st\11.1.0\bin;     
    C:\Windows\system32;     
    C:\Windows;     
    I notice that there are .cmd scripts that set the Path.
    This script sets the path to look in: c:\oapps\db
    cd C:\oapps\db\tech_st\11.1.0
    VIS_black.cmd
    echo %PATH%
    C:\oapps\db\tech_st\11.1.0\perl\5.8.3\bin\MSWin32-x86-multithread\;
    C:\oapps\db\tech_st\11.1.0\bin;
    This script sets the path to look in: c:\oapps\apps
    set PATH=""
    cd c:\oapps\apps\apps_st\appl
    VIS_black.cmd
    echo %PATH%
    C:\oapps\apps\apps_st\appl\au\12.0.0\bin;
    I'd like to install OBIEE on the same server. Obviously, I don't want any path conflicts. And, OBIEE uses a different version of java.
    1)
    Do all these Apps directories need to remain in the global PATH environment variable? Or, can the directories be removed from the path, and the scripts can be relied on to set the appropriate variables?
    Thanks a lot!

    if you want global settings (always present, even after reboot), you have to edit the autoexec.bat file, e..g
    SET CLASSPATH=c:\myclasses
    you can set environment variables temporarility in a DOS shell using the same command.
    if possible, you should avoid the CLASSPATH environment variable, and use the -cp or -classpath option for java and javac. This helps a lot to solve classpath confusions.

  • [SOLVED] bash - diff btwn 'normal' environment variables and VAR=x cmd

    I always assumed variables passed like this:
    VAR=value cmd
    are passed to the program in the same way as environment variables. However; this is not the case; who can explain this?
    $ svn commit
    svn: E205007: Commit failed (details follow):
    svn: E205007: Could not use external editor to fetch log message; consider setting the $SVN_EDITOR environment variable or using the --message (-m) or --file (-F) options
    svn: E205007: None of the environment variables SVN_EDITOR, VISUAL or EDITOR are set, and no 'editor-cmd' run-time configuration option was found
    $ VISUAL=$VISUAL svn commit
    Sending file
    Deleting file
    Adding file
    Transmitting file data ..
    Last edited by Spider.007 (2014-04-24 17:55:49)

    I'm curious too.  I could at least *speculate* on how it could go wrong the other way around: if the envoked process spawns a new process that inherits a more general environment than the parent's, the first could work and the second could fail - but these results indeed should not happen.
    Test code as evidence that the variables are passed in the same way:
    #include <stdio.h>
    int main(int argc, char **argv, char **env) {
    char **envp;
    for (envp = env; envp && *envp; envp++) printf("%s\n", *envp);
    return 0;
    Basically this is a very basic `env'.  It shows all environment variables known to the process.  No matter how they are set, they are all placed in env.
    NOTE: most programs will use getenv() rather than the extra parameter to main(), but this is meant to test what is passed where.
    Last edited by Trilby (2014-04-24 13:07:21)

  • From Where should i download Servlets and how to set Environment variables?

    Hi,
    I want to download the Servlets Kit for my development of application,but couldnt find it.I found a zip file containing all class files.If that is the correct one,then how should i set my environment variables?
    thanks
    rao

    Your files should come in a folder with the name "Javax" and subfolders right?
    What you can do is to paste the file "Javax" in your folder of your JDK installation.
    For example, I have installed my JDK in C:\Java\jdk1.3
    I added one new folder in C:\Java\jdk1.3 called classes.
    Then I would put the Javax folder in classes.
    PS : We add one new folder called classes so that in future when you want to add new classes you can just into this folder.
    Then in your enviroment settings, simple point to C:\Java\jdk1.3\classes;.;
    This works for me. Hopefully you will no problems!
    jing
    170902

  • Environment variable and spring

    Hi all, we are getting this when trying to run our app in Oracle 904:
    org.springframework.beans.factory.access.BootstrapException: Define an environment variable [java:comp/env/ejb/BeanFactoryPath] containing the class path locations of XML bean definition files; nested exception is javax.naming.NameNotFoundException: No object bound for java:comp/env/ejb/BeanFactoryPath
    javax.naming.NameNotFoundException: No object bound for java:comp/env/ejb/BeanFactoryPath
         at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.java:116)
         at javax.naming.InitialContext.lookup(InitialContext.java:345)
         at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:123)
         at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:85)
         at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:121)
         at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:71)
         at org.springframework.context.access.ContextJndiBeanFactoryLocator.useBeanFactory(ContextJndiBeanFactoryLocator.java:64)
         at org.springframework.ejb.support.AbstractEnterpriseBean.loadBeanFactory(AbstractEnterpriseBean.java:117)
         at org.springframework.ejb.support.AbstractStatelessSessionBean.ejbCreate(AbstractStatelessSessionBean.java:63)
         at MethodInvokerHome_StatelessSessionHomeWrapper1.callCreate(MethodInvokerHome_StatelessSessionHomeWrapper1.java:115)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.ejb.StatelessSessionEJBHome.getContextInstance(StatelessSessionEJBHome.java:275)
         at MethodInvokerRemote_StatelessSessionBeanWrapper0.invoke(MethodInvokerRemote_StatelessSessionBeanWrapper0.java:77)
         at java.lang.reflect.Method.invoke(Native Method)
         at org.springframework.remoting.rmi.RmiClientInterceptorUtils.doInvoke(RmiClientInterceptorUtils.java:103)
         at org.springframework.ejb.access.SimpleRemoteSlsbInvokerInterceptor.doInvoke(SimpleRemoteSlsbInvokerInterceptor
    Basically the app server thinks there is no environment entry but I have it declared in ejb-jar.xml descriptor:
    <env-entry>
    <env-entry-name>ejb/BeanFactoryPath</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>applicationContext.prod.xml</env-entry-value>
    </env-entry>
    Any ideas,
    J

    u need display in order to have a graphical env with font, raster and all this information is taken from the ip address to which u have set the DISPLAY
    Also make sure xwindows is running. U can check whether DISPLAY has been configured properly by running xclock
    Best Regards
    Rajesh Alex

Maybe you are looking for