Runtime.exec and setting environment variables

Runtime.exec and setting environment variables
I need a decent example which works on Windows.
Got any?

Thank you.
I was hoping for an example of the use of
http://java.sun.com/j2se/1.4.1/docs/api/java/lang/Runti
e.html#exec(java.lang.String,%20java.lang.String[]) or
http://java.sun.com/j2se/1.4.1/docs/api/java/lang/Runti
e.html#exec(java.lang.String,%20java.lang.String[],%20j
va.io.File) which take environment variable
information such as PATH.
The reason is because there is a library which is
being loaded via loadLibrary (
http://java.sun.com/j2se/1.4.1/docs/api/java/lang/Syste
.html#loadLibrary(java.lang.String) ). However, for
the child process to find the library the PATH needs
to be updated.
Any example regarding changing the PATH variable via
Java so that libraries can be loaded and processes
created? (Perhaps, I should make a new post and
restate the question with this more explicit
information?)
That won't work. LoadLibrary occurs in the JVM environment. As I said you can't change the JVM environment via exec().
If the shared library needs something in the path then you are going to have to set the path before your application starts up.
If you just need to load the library from someplace that is not on the path then you should be using System.load().

Similar Messages

  • 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 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.

  • Mountain Lion: how set environment variables

    Am I correct that for Mountain Lion, if not earlier, the only way to set environment variables at the system level is to use (or create) a file /etc/launchd.conf that contains commands such as:
    setenv CATALINA_BASE /opt/local/share/java/tomcat6
    (That does seem to work as expected.)
    If so, how does one do this by referencing the value of something else, e.g., to set JAVA_HOME? I tried
    setenv JAVA_HOME $(/usr/libexec/java_home)
    but then in Terminal if I run
    echo $JAVA_HOME
    I just get back $(/usr/libexec/java_home).
    By contrast, if I put that same setenv JAVA_HOME $(/usr/libexec/java_home) command into my ~/.profile, then the result of echo $JAVA_HOME is the actual value referenced, namely, /Library/Java/JavaVirtualMachines/jdk1.7.0_15.jdk/Contents/Home.

    Linc Davis wrote:
    launchd is not a shell and does not peform expansion. You have to use literal expressions. But you can also modify the bash environment system-wide by editing the file /etc/profile.
    But sudo emacs /etc/profile won't let me edit this file: it's read-protected, emacs says.
    What permissions should I give it? Right now it's in group wheel, owned by root but with Read permission only.
    P.S. And is it really a good idea to edit /etc/profile -- assuming I can suitably set the permissions to do so? Apple goes out of its way to try to hide this file: /etc is a link to /private/etc, e.g.

  • Forget to set environment variable export SAPINST_USE_HOSTNAME

    Dear Experts
    we have installed the SAP ECC6.0 EhP4 in HACMP environment with AIX6.1 ,Power HA cluster6.1, oracle 11g database
    the problem is while installing the CI and ASCS and Dialog instance I  missed  to set environment variable
    export SAPINST_USE_HOSTNAME = <virtual Host Name> and while starting the sap-inst also i didn't start as like
    ./sapint SAPINST_USE_HOSTNAME  = <virtual Host Name>,Now i am facing problem while doing cluster fail over to another node
    Node A host Name is not reflecting in Node B and I am not able to start  the SAP with host name of Node A
    in AIX6.1 in IBM Admin they didnt give any virtual host name they said that they  have configured  the cluster with two service IP there is no virtual IP in AIX6.1
      please help me out how to resolve this host Name issue and to start the SAP in Node B
    Thanks in Advance
    krishna

    Hi Krishna,
    I dont agree with the AIX 6.1 having no virtual ip's, because i recently installed a HA instance with ASCS, SCS & also ERS on 6.1
    to answer your questions:-
    "can you tell is this correct setup or anything we did mistake for file system setup and installation"
    This depends on what your requirement is. Typically a cluster will have Oracle on one host and SAP on the other host. Ill explain the VCS concept, so you will have a better understanding.
    Lets consider Node1 & Node2. Now each node will have a physical IP and a virtual IP. The Virtual IP will be associated with a set of file systems. For example /oracle will be associated to virtual ip lets say "xyzDB" & the /usr/sap/<sid>, TRANS & sap mount will be associated with virtual ip lets say "abcCI". Now when the cluster fails over to which ever node, these file systems will still be associated with their respective virtual ip's.
    So, the start profile will always have START_DVEBMGS_abcCI. Irrespective of which Node the sap is in, when you start the SAP, it will use the virtual hostname and start up SAP. I hope your getting the concept.?
    Coming back to the setup, since you have ASCS, Oracle , CI & a dialog instance. Im not sure what file systems you have associated with VCS groups. Can you give command "hastatus -sum" and post the output?
    Regarding your other question
    "this file system is moving to Node B but while starting SAP on Node B host Name is not reflecting and SAP is not coming up  due to there hostname didnt change in Node B,, can you advice me please ,,"
    This is inline with what i explained above for cluster mechanism. The physical IP will not change. It is only the virtual IP that is associated with a set of file systems.
    Ill give you one more example, Consider the parameter rdisp/mshost = <> . What should this be? Physical host or Virtual host?? :-) .It should be Virtual. Because the CI can be in Node1 or Node2. If we give the physical host, then if the SAP fails over to the other node. How will it start up? because the profiles still say the message server is in the other host... Getting my point?
    Regards,
    Shanser

  • Runtime Exec and ProcessBuilder

    I have an object (textTicket) which is a formatted transaction label. Here is an example:
    CROSS PLAINS QUARRY CROSS PLAINS TN 37049 2549
    MATL SPREADING NOT GUARANTEED
    615-654-9942 TOLL FREE 877-654-9942
    Date: 01/19/2009 04:45:46
    Job No: PU-2008
    Q Num::
    Cust No: 30000001 Src Num::
    Sold To: CASH SALE
    Address: INTERNAL
    NASHVILLE,TN 37202
    Ord By:
    Ord No: Rate Zone:
    Location:THANKS YOU
    Mat. & Haul170.28 Sev Tax:0 Tax16.60
    Acc Total:1308.16
    Total186.88
    3/4 TO 4/67'S
    Gross: 40500 St. Item:
    Tare: 12120 P.O.: MIKE MILLER
    Net: 28380.0
    Net Tons: 14.19
    Proj:
    Truck #: 1
    Hauler: Phy Truck: 248251
    I am attempting to pass this textTicket object to a shell script that will send it out the port for printing. I have tried using the Java Comm API however, we have intermittent problems with the API running on an Oracle Appserver. Sometimes, the data never gets sent to the port. So what I am trying to do is just call a shell script that echos the textTicket out the port via redirection. The problem arise when I use the ProcessBuilder or runtime exec and I have to convert the textTicket to a string via textTicket.toString. The textTicket then losing all of its formatting. Any ideas on how to keep the formatting as I am passing the textTicket to the shell script.

    My example did not save into the post very well. For instance, the first line "Cross Plains Quarry" should be center on the paper. The object contains \t\t to get it center.
    For example on the runtime.exec, I am doing the following
    public void printShell(String port, String string){
         String[] params={"/usr/ts/bin/prttick.sh", string, port};
         try {
                   Process p=Runtime.getRuntime().exec(params);
              } catch (IOException e) {
                   // TODO Auto-generated catch block
                   SerialCommunicator.logger.debug("error" + e.getMessage());
    The variable string is textTicket.toString();

  • Set environment variables

    Does a user need to have certain rights or access to certain libraries to
    set environment variables off or on when running a pl/sql script?
    environment variables such as:
    set echo off;
    set termout off;
    thanks

    It is possible to disable certain SQL*Plus, SQL and PL/SQL commands, using the PRODUCT_USER_PROFILE table (note that this only affects the SQL*Plus environment).
    See: http://download-west.oracle.com/docs/cd/B10501_01/server.920/a90842/ch10.htm#1005596

  • How to set environment variable ORACLE_HOME ?

    Hi
    I trying to install SAP Solution manager 4.0 SR3:
    OS: Linux RHEL4u4
    DB: Oracle
    SAPinst now stops the installation.
    To proceed with the installation, install the Oracle database as follows:
    1.Log in as user orassm.
    2.Set the DISPLAY variable.
    3.Change to directory /oracle/stage/102_32/database/SAP.
    4.Start './RUNINSTALLER'.
    After you installed the Oracle database software, proceed with the database instance
    installation by choosing 'OK' in this dialog box.
    ./RUNINSTALLER
    oracle_stage is not set (OK)
    oracle_base is not set (OK)
    oracle_home is not set (OK)
    oracle_sid is not set (OK)
    oracle_home_name is not set (OK)
    oracle_inst_group is not set (OK)
    from_location is not set (OK)
    tmp_netca_file is not set (OK)
    tmp_dbca_file is not set (OK)
    Working in /oracle/stage/102_32/database/SAP ...
    The environment variable ORACLE_HOME is not set! abort ...
    How to set environment variable ORACLE_HOME ?
    Regards
    Eric

    i
    Switch shell to bash:
    orassm:x:502:503:SAP Database Administrator:/oracle/SSM:/bin/bash
    [root@csp-p-sm00 ~]# su - orassm
    [orassm@csp-p-sm00 ~]$
    But when try to run ./RUNINSTALL
    [orassm@csp-p-sm00 SAP]$ ./RUNINSTALLER
    oracle_stage is not set (OK)
    oracle_base is not set (OK)
    oracle_home is not set (OK)
    oracle_sid is not set (OK)
    oracle_home_name is not set (OK)
    oracle_inst_group is not set (OK)
    from_location is not set (OK)
    tmp_netca_file is not set (OK)
    tmp_dbca_file is not set (OK)
    Working in /oracle/stage/102_32/database/SAP ...
    The environment variable ORACLE_HOME is not set! abort ...
    Additionaly I've post csh.cshrc and csh.login
    /etc/cshrc
    csh configuration for all shell invocations.
    by default, we want this to get set.
    Even for non-interactive, non-login shells.
    [ "`id -gn`" = "`id -un`" -a `id -u` -gt 99 ]
    if $status then
            umask 022
    else
            umask 002
    endif
    if ($?prompt) then
      if ($?tcsh) then
        set prompt='[%n@%m %c]$ '
      else
        set prompt=\[`id -nu`@`hostname -s`\]\$\
      endif
    endif
    if ( $?tcsh ) then
            bindkey "^[[3~" delete-char
    endif
    setenv MAIL "/var/spool/mail/$USER"
    limit coredumpsize 0
    if ( -d /etc/profile.d ) then
            set nonomatch
            foreach i ( /etc/profile.d/*.csh )
                    if ( -r $i ) then
                            source $i
                    endif
            end
            unset i nonomatch
    endif
    /etc/csh.login
    System wide environment and startup programs, for login setup
    if ($?PATH) then
            if ( "$" !~ /usr/X11R6/bin ) then
                    setenv PATH "$:/usr/X11R6/bin"
            endif
    else
            if ( $uid == 0 ) then
                    setenv PATH "/sbin:/usr/sbin:/usr/local/sbin:/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin"
            else
                    setenv PATH "/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin"
            endif
    endif
    setenv HOSTNAME `/bin/hostname`
    set history=1000
    if ( ! -f $HOME/.inputrc ) then
            setenv INPUTRC /etc/inputrc
    endif
    Regards
    Eric

  • 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

  • Apex listener installed no test and set bind variables buttons

    I have installed Apex listener and while creating restful service module i dont see test and set bind variables buttons in the source region.
    I went through the many posts. Installed apex listener successfully.
    getting http://localhost:8080/ords/ started message when i start the listener.
    and using Apex URL as http://localhost:7780/pls/htmldb.
    What are the possibilities for this issues?
    Please help me on this.
    Thanks
    Chandran

    Apex listener version is 2.0.9
    Apex version is 4.2

  • How to set environment variables in WL ?

    Hi,
    How to set environment variables in WL ?
    Thanks,
    Srivi

    Hi,
    You can set the environmet variable in Weblogic by using the below commands
    setWLSEnv.cmd/sh ==>Set the CLASSPATH to include the WebLogic Server classes.
    Overview of WebLogic Server Domains
    or you can use to set the Environment variable along with domain specific varables using the SetDomainEnv.cmd
    To run SetDomainEnv.sh in Linux please use
    . ./setDomainEnv.sh it require two dots (Dont miss it )
    http://docs.oracle.com/cd/E28280_01/web.1111/e13749/weblogicserver.htm#ADMRF205
    Hope it helps

  • Reading InputStream from Runtime.exec() and ffmpeg?

    I've got a lot of things going on here and I'm having trouble debugging. I'm working on a streaming music player, and the platform only handles MP3 natively. Specifically, the method that handles incoming requests has to return an InputStream for further processing upstream (out of my visibility).
    I'm trying to extend the music player to play AAC files with the extension ".m4a". To do this, my plan is to transcode from MP3 to AAC using Runtime.exec() and ffmpeg, and then return an InputStream that contains the MP3. This works fine if I use ffmpeg to transcode to a temp file, and then return a FileInputStream constructed from that temp file. But like I said, this is supposed to be a steaming music player, and the blocking for the ~30 seconds it takes to completely transcode to a file is too much of a delay.
    So what I'm trying to do is have ffmpeg transcode to stdout, and then use Process.getInputStream() to return the InputStream that contains ffmpeg's stdout while the transcoding is still going on. This doesn't work and I'm not sure why. (I'm fairly new to java, and this is the first time I've used Runtime.) My player just hangs there. I know Runtime is picky about exhausting the stdout and stderr streams, so I'm not sure if it's something related to that, or if I somehow need to buffer the stdout before returning it, or if I need to run something in a different thread, or if I'm just completely barking up the wrong tree.
    If anyone has any experience with something like this, or can point me at some code that implements something similar, I'd appreciate the help.
    Below a sample of the code in question. Also, for what it's worth, all of the console messages that I put in there are printing, but the music doesn't play.
       public InputStream getStream(String uri) throws IOException
                 System.out.println("Entering Factory.getStream()");
                  System.out.flush();
                File file = new File(URLDecoder.decode(uri, "UTF-8"));
                if (file.exists())
                     if(file.getPath().toLowerCase().endsWith(".mp3")) {
                            // This code for playing MP3 files works correctly
                          System.out.println("Playing MP3");
                          System.out.flush();
                          InputStream in = new FileInputStream(file);
                          return in;
                     else if(file.getPath().toLowerCase().endsWith(".m4a")){
                          System.out.println("Playing M4A");
                          System.out.flush();
                          // Create array for ffmpeg command line
                            // This command line transcodes to STDOUT
                          String[] command = { this.ffmpeg_path,
                                                             "-i", 
                                                             "input.m4a",
                                                             "-acodec",
                                                             "libmp3lame",
                                                             "-ac",
                                                             "2",
                                                             "-ab",
                                                             "256",
                                                             "-f",
                                                             "mp3",
                          // Begin transcoding with ffmpeg
                          System.out.println("Transcoding...");
                          System.out.flush();
                          Runtime runtime = Runtime.getRuntime();
                          Process ffmpeg = runtime.exec(command);
                          // Must exhaust error stream, or the application can become deadlocked.
                          System.out.println("Exhausting stderr...");
                          System.out.flush();
                          this.exhaustInputStream(ffmpeg.getErrorStream());
                          // Return ffmpeg's stdout as an input stream
                          System.out.println("Returning stdout...");
                          System.out.flush();
                          return ffmpeg.getInputStream();
                     else {
                          System.out.println("Unsupported Audio File");
                          System.out.flush();
                          return null;
                else
                    // We aren't requesting a file, so let the API handle the request upstream...
                    return super.getStream(uri);
         private void exhaustInputStream(final InputStream inputStream) {
                  // Since InputStream.read() blocks, exhast the stream in a separate thread
                  new Thread() {
                       public void run() {
                            try {
                                 while(inputStream.read() >= 0) {
                                      // Just throw the bytes away
                            catch(IOException e) {
                                 e.printStackTrace();
                  }.start();
             }

    Read this article
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

  • Installed jre and jdk and setup environment  variable

    installed jre and jdk and setup environment variable but still i am not able to rum program?
    cannot find symbol class string
    package system does not exist

    if removing 1 jre will help your disk space problems
    then you urgently need a bigger disk.
    Btw i never notice Java installing 2 different JRE's
    so i dont think it will harm remvong one, make sure
    you dont delete one you are using :)I assume that you don't run MS os; that's the only one that installs 2 JRE's.
    To OP: This has been discussed by Sun, but no changes have been announced. Maybe the relocation in version 1.5 of the private (aka developer) code to the Program Folder is a start of this change?

  • 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

  • Setting UI60_ICON and other environment variables

    Hi, I am developing using forms 6i. I tried setting the UI60_ICON environment variable from
    1. The Control Panel -> System -> Advanced -> Environment Variable -> System Variables and
    2. The Registry Editor -> Edit ->New -> String Value
    But my icons will still not appear in my forms. Can some one help me.
    I do not add the .ico extension when I use the icon name. And I also make sure the icon has been place in the path I have stated. The icon appears when I place them in the FORMS60 environment variable.
    I need help.

    Try to set with Registry Editor
    HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE (where you see FORM_PATH and other)
    variable
    UI_ICON instead UI60_icon
    Hope helps

Maybe you are looking for

  • Please help me easily move my photos off the adobe photoshop 3 edition that is gonna close to revel.

    help me move my photos from adobe photoshop 3.0 edition that is gonna close soon. i just want it on revel so i can copy, print or put on a stick please please please

  • Very old 'Sent' mail missing from mailbox - help?

    I've got a question about (really) old mail in my Sent mailbox. I went today to look for some very old messages (around 9/2001), and the earliest mail available to me is from Jan 1, 2003. Does Mail archive or delete mail after it passes a certain age

  • In App Purchased Refund

    Last few month, i have make in app purchase , all total amount is around 2500 euro in a online game , but recently i reliazed that , the online game is hiding or locking some item in the game , so even how much u spend u can't get the item . And the

  • MDDataSetBW.GetCellData. See RFC trace file or SAP system log for more...

    Ingo, I am getting below error message in BO Test environment when I refresh WebI document. MDDataSetBW.GetCellData. See RFC trace file or SAP system log for more details It was working when we migrated the objects initially. Subsequently when we try

  • OBIEE Prompt

    Hi All, I am using OBIEE 10.1.3.4.1. I have an issue with prompt. I have created a prompt on "PO Number". It is working in two different reports. But when I am using this prompt in another report it is not showing the selected value. Though I have pr