How to set #HOST# variable used in Chart template using Multiple Domains?

I have a extended question to How can I set #HOST# variable referenced in the Chart template?
In addition to the Proxy layer, we are looking to use multiple sub-domain names into the same Oracle APEX instance (through the one DAD) each mapped to a different application id. Therefore I don't think the solution in the link will work for me - as this embeds a single domain name in the DADS.CONF.
Two questions:
- Is it possible to set the "HTTP_HOST" in "dads.conf" using an existing HTTP Header value? - my proxy can pass on the original domain as "HTTP_X_FORWARDED_HOST". So if it was possible to use (say: using whatever form/syntax of parameterisation is available) ?
>
PlsqlCGIEnvironmentList HTTP_HOST=%{HTTP_X_FORWARDED_HOST}
>
If it can then that would work for me. It would be great if modl_plsql handled this out of the box as I understand the "X-FORWARDED" approach is pretty standard in the proxy world including passing on original IP addresses. Hitting an phpinfo() site shows headers
>
HTTP_X_FORWARDED_FOR     192.168.2.100
HTTP_X_FORWARDED_HOST     dev.mycompany.com:443
HTTP_X_FORWARDED_SERVER     mycompany.com
>
- Alternatively is it possible in APEX environment to set the #HOST# from the HTTP Header "HTTP_X_FORWARDED_HOST" if it exists for all requests?
Thanks

Hi Donna,
changing the CGI environment variables HTTP_HOST, REQUEST_PROTOCOL and SERVER_PORT is the correct way how to resolve this, because it appears that your hiding the web server where you have installed mod_plsql or EPG by a different outside facing web server (also called reverse proxy). That's why APEX gets the host name, protocol and port of the internal web server, but should actually get the values of your reverse proxy web server. Can can fix that by changing the following CGI environment variables.
HTTP_HOST should just contain the domain name (no protocol or port). For example: www.oracle.com
REQUEST_PROTOCOL should contain http or https
SERVER_PORT should be the port for https
I don't want to add a new cgi variable called HOST because HOST sounds so generic and it might interfere with something else running in our environment. Or, I don't want to change the plsql cgi environment variable (such as HTTP_HOST) because many developers may use owa_util.get_cgi_env('HTTP_HOST') to get the current server. If the SERVER_PORT is part of the #HOST# then what could I change it to if it needs to be null. If you leave it blank, then the default SERVER_PORT comes from the CGI variables.The value of HTTP_HOST is wrong anyway and points to your internal web server, but I assume your developers actually want to get the host name of your external web server if they use it to generate absolute URLs. That's why I wouldn't bother and set it to the correct host name.
Regards
Patrick
My Blog: http://www.inside-oracle-apex.com
APEX Plug-Ins: http://apex.oracle.com/plugins
Twitter: http://www.twitter.com/patrickwolf

Similar Messages

  • How can I set #HOST# variable referenced in the Chart template?

    #HOST# and #HOST_PROTOCOL# are being set incorrectly by APEX from CGI variables when I create a chart. I am using APEX 4.1 and Oracle 11g. The get the continual "Loading data..." and then after it times out I get "Error loading file".
    Before we changed to a secure http environment, our charts worked. After we changed to the new web layer, the charts do not work. The #HOST# substitution was set to http://correctservername/ and #HOST_PROTOCOL# was set to http. We set PlsqlCGIEnvironmentList REQUEST_PROTOCOL=https in the dads configuration file and now the #HOST# displays https but it also includes the default port number which we do not want (https://correctservername:port/) The charts work without the port. REQUEST_PROTOCOL is not in the cgi list and setting this variable set #HOST_PROTOCOL#. What variable can we set to make #HOST# correct. It seems like #HOST# is being set by #REQUEST_PROTOCOL#'://'||HTTP_HOST||':'||SERVER_PORT||SCRIPT_NAME||'/'. SERVER_NAME could also be used in of HTTP_HOST. I don't know how APEX is setting #HOST#. Does it come from a host alias somewhere in the environment?
    I don't want to add a new cgi variable called HOST because HOST sounds so generic and it might interfere with something else running in our environment. Or, I don't want to change the plsql cgi environment variable (such as HTTP_HOST) because many developers may use owa_util.get_cgi_env('HTTP_HOST') to get the current server. If the SERVER_PORT is part of the #HOST# then what could I change it to if it needs to be null. If you leave it blank, then the default SERVER_PORT comes from the CGI variables.
    I would rather not create a global variable (hard-coding) and create a new chart template using the global variable or create a before header application process to re-direct url without a port.
    Edited by: Donna C-Houston on Oct 10, 2012 1:06 PM

    Hi Donna,
    changing the CGI environment variables HTTP_HOST, REQUEST_PROTOCOL and SERVER_PORT is the correct way how to resolve this, because it appears that your hiding the web server where you have installed mod_plsql or EPG by a different outside facing web server (also called reverse proxy). That's why APEX gets the host name, protocol and port of the internal web server, but should actually get the values of your reverse proxy web server. Can can fix that by changing the following CGI environment variables.
    HTTP_HOST should just contain the domain name (no protocol or port). For example: www.oracle.com
    REQUEST_PROTOCOL should contain http or https
    SERVER_PORT should be the port for https
    I don't want to add a new cgi variable called HOST because HOST sounds so generic and it might interfere with something else running in our environment. Or, I don't want to change the plsql cgi environment variable (such as HTTP_HOST) because many developers may use owa_util.get_cgi_env('HTTP_HOST') to get the current server. If the SERVER_PORT is part of the #HOST# then what could I change it to if it needs to be null. If you leave it blank, then the default SERVER_PORT comes from the CGI variables.The value of HTTP_HOST is wrong anyway and points to your internal web server, but I assume your developers actually want to get the host name of your external web server if they use it to generate absolute URLs. That's why I wouldn't bother and set it to the correct host name.
    Regards
    Patrick
    My Blog: http://www.inside-oracle-apex.com
    APEX Plug-Ins: http://apex.oracle.com/plugins
    Twitter: http://www.twitter.com/patrickwolf

  • How to set a variable in portal session using web dynpro java.

    Hi,
    I have created a web dynpro application, which is running inside portal. I have created a role called "R1". Inside role R1, i have created 3 workset W1, W2 and W3. and inside each workset i have some pages and iviews.
    My requirement is when user logins to the portal , and when he clicks on role R1 for the first time, a login page should come (so that we can do revalidation), and when he enters his password again in that login page , then only workset W1, W2 and W3 should be visible/accessible to him and after successful revalidation, if he clicks again on role R1, in that particular portal session, than that login page should not come.
    for this, i thought i will set a variable in portal session, whenever user successfully revalidated himself, and if after successful revalidation he clicks again on role R1, i will check in doinit method of webdynpro whether variable is set or not (which i already set on successful revalidation), and if it is set then i will do Donavigation else i will present login page to the user.
    Can anyone tells me how to set a variable in portal session using web dynpro java.
    thanks
    Arush

    Hi,
    Try this:
    WDScopeUtil.put(WDScopeType.CLIENTSESSION_SCOPE, key, value)
    WDScopeUtil.get(WDScopeType.CLIENTSESSION_SCOPE, key)
    Ex:
    WDScopeUtil.put(WDScopeType.CLIENTSESSION_SCOPE,"Key1","Value1");
    String value1=WDScopeUtil.get(WDScopeType.CLIENTSESSION_SCOPE,"Key1").toString();
    /people/william.cui/blog/2007/02/12/sharing-session-context-between-parent-and-external-windows-running-on-same-host
    Regards,
    Charan

  • How to set up Airport Extreme with Charter ARRIS Modem TM902A for the first time for WIRELESS.

    How to set up Airport Extreme with Charter ARRIS Modem TM902A for the first time for WIRELESS.
    When Charter Tech goes to your site, have them connect the modem up, but do not connect the modem to your iMAC or MacBook Pro.  What you want to do is connect the Airport Extreme to the iMac or MacBook Pro first with the Ethernet Cable. You have to do this to configure via Airport Utility to set up the Base Station Name & Base Station Password.
    You will then create/configure a Wireless Network, create your Wireless Password that will be entered on each of your Devices, example, Apple Tv, your iPhone, etc., you want to allow access to your Wireless Network you are creating.
    Wireless Security will be -> WPA/WPA2 personal or just WPA2
    Enter the Wireless Password you want
    Verify the Wireless Password (enter it again)
    After it is created you will see it on the Airport Utility window with the name you created for it and to the left, will be a Dot (circle that will be yellow).
    Next you then want to unplug the power to the Airport Extreme, and then take the end of the Ethernet cable you unplugged from the iMac or Lap top MacBook Pro and connect it to the back of the Modem.
    Next unplug the power cord from the modem and wait about 5 minutes, then plug the power back into the Arris Modem and wait until all lights come back on the modem wait
    about 5 minutes, then plug the power cord back to the Airport Extreme and you will see it the light blinking yellow.  Wait about 5 to 10 minutes, during this time Restart you IMAC or MacBook Pro, and once it is back up click on the Airport Utility and you should see on the Airport Utility screen.
    For INTERNET to the left the light should be green and you should see the Airport Extreme also appear and the light to the left on the screen should also be green.  If they are, you then should be able to click on the Wireless Symbol on top of bar of the screen and click to select the Wireless Network Name you created.
    If you Do Not See the light (Icon) next to INTERNET turn Green, or if you see the Internet Light Green, but the Light (Icon) next to the Airport Extreme is yellow, unplug the power again to the modem and unplug the power again to the Airport extreme and wait about 15 minutes or up to 30 minutes. Then plug the power cord back to the modem wait till all the lights light up then, plug the power cord back into the Airport Extreme and Restart your iMAC or MacBook Pro.
    The Airport Extreme light should change from yellow to green. Open up the Airport Utility to see what the indicators are showing they should both be green.  Again select Wireless network you created under the Wireless Icon on the top right of the screen. Open Safari and see if you are able to Route to a web page or the apple site should appear.
    WHAT TO DO IF YOUR AIRPORT EXTREME WAS PREVIOUSLY SET UP FOR USE WITH ANOTHER CARRIERS ROUTER OR MODEM.
    NOTE:  If you already had your Airport Extreme connected for example, I previously had ATT Uverse and the Airport Extreme was connected to the Wireless Router Model 3801HGV, I disabled the Uverse Wireless and used the Airport Extreme for the Wireless signal in bridge mode, as the Airport extreme Signal is much stronger than the Uverse router, and I was able to obtain a Wireless signal with the Airport Extreme way much better with no signal loss which was very very frustrating with the Uverse router.
    Anyhow if you had it hooked up like this, now that you will be using it with the Charter ARRIS Modem TM902A, you will need to reset the Airport Extreme to clear out the old data it has in memory, with the previous set up otherwise it will not work. Trust me I spent 6 hours trying to make it work reading all Apple Support Community questions and answers relating to this type issue/problem others have been having trying to get their set up working. I tried all the tips, and I finally decided just to see if by chance I would be able to connect with someone with Charter Tech support who might be familiar with Apple to be able to assist me and by luck I did.  He told me why it was not working and was all due the previous configuration with the ATT Uverse router was still in memory with the Airport Extreme. Finally it was 10:30 PM when I decided to call Charter Tech Support and I had been working on this since 3:00 pm pacific. I did not call them earlier as all the post I read said they never received any good help from Charter. After calling them I finished up by 11:00 PM and was able to finally connect Apple Tv, iMac, iPhones and Macbook Pro. We love our Apple Product and Happy all is connected with the new
    Internet Provider Charter. I must say the speed is way way much better than it ever was with AT&T Uverse. 
    THIS IS WHAT YOU WILL NEED TO DO:
    First you will need to unplug the Airport Extreme, then by taking the tip of a pen or paper clip end you need to push the reset button on the back of the Airport Extreme and hold it
    down and at the same time plug the power cord back into the Airport Extreme count to 5 or 10 then release the reset button. Then once he light in front of the Airport Extreme stops blinking you need to plug the Ethernet cable from the Airport Extreme to your iMAC or Macbook Pro, and restart which ever one you have, then open the Airport Utility once it is back up.  If you see airport extreme pop up with the old network name or it shows and yellow triangle click on the Airport Extreme ICON it will not let you configure it but will ask if you want to get rid of it or remove and just do it.  Then Again restart your iMAC or MacBook Pro, open up Airport Utility again, and on the top left you should see under “Other Airport Base Stations” the MAC ID for the Airport Extreme.
    You will then create/configure a Wireless Network, create your Wireless Password that will be entered on each of your Devices, example, Apple TV, your iPhone, etc., you want to allow access to your Wireless Network you are creating.
    Wireless Security will be -> WPA/WPA2 personal or just WPA2
    Enter the Wireless Password you want
    Verify the Wireless Password (enter it again)
    After it is created you will see it on the Airport Utility window with the name you created for it and to the left, will be a Dot (circle that will be yellow).
    Next you then want to unplug the power to the Airport Extreme, and then take the end of the Ethernet cable you unplugged from the iMac or Lap top MacBook Pro and connect it to the back of the Modem.
    Next unplug the power cord from the modem and wait about 5 minutes, then plug the power back into the Arris Modem and wait until all lights come back on the modem wait
    about 5 minutes, then plug the power cord back to the Airport Extreme and you will see it the light blinking yellow.  Wait about 5 to 10 minutes, during this time Restart you IMAC or MacBook Pro, and once it is back up click on the Airport Utility and you should see on the Airport Utility screen.
    For INTERNET to the left the light should be green and you should see the Airport Extreme also appear and the light to the left on the screen should also be green.  If they are, you then should be able to click on the Wireless Symbol on top of bar of the screen and click to select the Wireless Network Name you created.
    If you Do Not See the light (Icon) next to INTERNET turn Green, or if you see the Internet Light Green, but the Light (Icon) next to the Airport Extreme is yellow, unplug the power again to the modem and unplug the power again to the Airport extreme and wait about 15 minutes or up to 30 minutes. Then plug the power cord back to the modem wait till all the lights light up then, plug the power cord back into the Airport Extreme and Restart your iMAC or MacBook Pro.
    The Airport Extreme light should change from yellow to green. Open up the Airport Utility to see what the indicators are showing they should both be green.  Again select Wireless network you created under the Wireless Icon on the top right of the screen. Open Safari and see if you are able to Route to a web page or the apple site should appear.

    I just got a Charter Modem. Model TM822. While I was moving, my Airport Extreme was still at my old place.
    I have a Linksys WRT320N I used for the initial Charter setup.
    I can get my Airport to work here, but the Internet light on the Modem flashes Yellow.
    Hasn't caused any issues so far but one thing I did notice.
    On the Linksys there were 3 DNS servers listed.
    The Airport Extreme only lists 2 and i don't see where I could add another, only change whats already there.
    I tried everything above, but light on modem still flashes yellow.
    I have the technicians cell phone. Told me "that shouldn't be" and gave the same advice listed above.
    I'll break down and call Charter one day, see if it's on their end. NSA tracking may need a reset LMAO.

  • How to set enviroment variables for Inso Filter

    Hi everyone,
    I want to convert word documents to html using CTX_DOC.Filter.According to the documentation,I know I neednot set the 'Inso Filter'in the preference when creating index,but I must set enviroment variables for Inso Filter.
    I found the following instructions for it in the 8.1.5 documentation,but I can't understand it well.Is there anyone can tell me how to set enviroments variables for Inso Filter on Windows2000 Server?(My DB version is 8.1.7EE)
    Environment Variable Locations
    All environment variables related to Inso filtering must made visible to interMedia Text. Set these variables in the following locations:
    listener.ora file. This makes the environment variables visible to the extproc PL/SQL process.
    The operating system shell from where ctxsrv server is started. This makes the environment variables visible to the ctxsrv process, which does background DML.
    Any suggestions are apreciated
    Reemon
    null

    NSAPI plugins are normally configured using parameters specified in magnus.conf and/or obj.conf. What plugin requires you set an environment variable?

  • How to set Environment variables........???

    I installed j2sdk in my system.....
    i want to know how to set env variables...?

    Which ones, what for? Did you check whether some are already set?
    Forget about the classpath variable, if you want to add that. Use the command-line arguments.
    And which OS?

  • 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

  • How to set a variable value on the BPC Data Manager

    Hello BPC Experts,
    I'm creating a BPC10 NW version demo environment for our prospect customer.
    I made a data manager to import  BW data into BPC model from BW cube.
    I need to import just one month data into BPC from the BW cube that has more than one month data.
    When I run the data package manually, I can select a member of the time dimension prompt and I can import specific month data I want.
    But, in a case where the program (data manager) runs by JOB monthly,
    I can't select a member of the time dimension prompt manually.
    So I want to know how to set a  variable value to the time dimension prompt from a system date etc. automatically.
    Are there any way to set a variable value to the time dimension prompt on the data manager automatically from a system date?
    Or, do you have any other solution to import just one month data into BPC from the BW cube that has more than one month data  by the data manager running on JOB ?
    (without selecting a member of the time dimension prompt of the data package manually)
    Thanks in advance,
    Keisuke

    Hi Gersh
    Sorry for my late reply and thanks for your helpful information.
    I tried the second way of your information and I could configure it.  
    And I 'll try first way of your information.
    Regards,
    Keisuke

  • How to set my own gui status when i use selection-screen

    how to set my own gui status when i use selection-screen command
    and
    how to set the names in the application tool bar when function keys are created

    Make sure that you do this in event "AT SELECTION-SCREEN OUTPUT".
    Run Txn ABAPDOCU and check 'DEMO_SEL_SCREEN_STATUS' for sample.
    Also check out following discussion -
    Selection Screen PF-STATUS
    Cheers,
    Sanjeev

  • Could anyone please let me know how to set a ICC profile with Acrobat dlls using Csharp or VB

    Could anyone please let me know how to set a ICC profile with Acrobat dlls using Csharp or VB

    Cant we even use the dlls in an application?
    In order to automate Acrobat, you need to have Acrobat installed. There is
    nothing you can do with just the DLLs. As was already stated, Acrobat is
    not licensed for use on a server, but regardless of that, it's also
    not technically suitable for server use. You need to find a solution
    outside of Acrobat to solve your problem.
    It also seems that you don't have a good understanding of what is going in
    inside a PDF file. PDF is a very complex file format, and based on
    your questions
    and followup questions, you need to spend a considerable amount of time
    getting familiar with the PDF file format to understand how color works in
    the PDF context. Reader the PDF spec, while paying special attention to the
    section about color. You will find out that if you want to convert the
    color space of a "PDF file", you actually need to convert the color space
    associated with every single object in your PDF file. That is fairly simple
    for vector graphic and text, but when it comes to images, you may have to
    convert the image data. Once you have a good understanding of what it is
    you need to do within the PDF file, then you can start looking for tools
    that allow you to do that. Again, Acrobat and therefore the Acrobat SDK is
    not suitable for this task. If you want to stay with Adobe products take a
    serious look at the PDF Library, which his licensed through Datalogics (
    http://www.datalogics.com/products/pdf/pdflibrary/). As you've mentioned,
    there are other, non-Adobe PDF libraries that you can also use, but this is
    the Acrobat SDK forum, so I won't discuss any of those 3rd party solutions.
    You are wasting your time while looking for a simple solution that does not
    exist.

  • How to set environment variables permanetly?

    I have installed oracle apps R12 on Oracle Enterprise Linux 5.3 successfully. When i run the file APPS<context_name>.env as oracle user(the one who installed software), the variables are set,,,but when i logout and login again,,,,,i dont see $ORACLE_HOME, $APPL_TOP etc......so please can someone tell me how to set the variables permanently..
    thanks

    Hi,
    set the env file in profile of unix user.
    if your shell is bash shell, then edit the user .bash_profile with env file. If your's is bourn shell, edit the user .profile
    for example,
    i have PROD as the database SID
    /oraprod and /applprod are the base mount points of database and application tiers respectively.
    erpserver is the hostname of R12 (single node)
    (1) Database Tier:
    login as oracle user
    $vi .bash_profile
    . /oraprod/db/tech_st/10.2.0/PROD_erpserver.env
    save the file
    (2) Application Tier:
    login as applmgr user
    $vi .bash_profile
    . /applprod/apps/apps_st/appl/APPSPROD_erpserver.env
    save the file
    ------

  • 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 the table input in Query template?

    Hi all.
    I need to call a Bapi_objcl_change, with import parameter and a table as an input. I have done this, in BLS. I have set the table input in the
    form of xml. In BLS, I get the output(the value gets change in SAP R3, what i have given in BLS).  But if i set the same xml structure  in
    query template, I didn't get the output. Table input parameter does not take that xml source.  How to set the table input in Query template?
    can anyone help me?
    Regards,
    Hemalatha

    Hema,
    You probably need to XML encode the data so that it will pass properly and then xmldecode() it to set the BAPI input value.
    Sam

  • 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

  • How to set environment variable?

    Hi,
    I just succeeded starting up an external executable by using nativeprocess.
    Now I have to set the portnumber as an environment variable.
    After setting this portnumber, I can send queries to the executable.
    But I don't now how to set this environment variable.
    You can see my try in bold:
    Starting the executable (an extract of the code):
    public var portnumber;
    file = file.resolvePath("C:\\Program Files\\CM Synergy 6.3\\bin\\start_dbase.exe");    #start executable
    process.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, getportnumber);    #get portnumber as output of the executable
    The next step is to define the variable portnumber:
    file = file.resolvePath("C:\\WINDOWS\\system32\\cmd.exe");
    processArgs[0] = "/C";
    processArgs[1] = "set";
    processArgs[2] = "portnumber=";
    processArgs[3] = portnumber;
    When I try to print out all environment variables, portnumber is not in:
    file = file.resolvePath("C:\\WINDOWS\\system32\\cmd.exe");
    processArgs[0] = "/C";
    processArgs[1] = "set";
    If I replace the last executable with my real command (running the query), the executable is giving the error that my portnumber is not set.
    Is it possible? I have also tried it with setx.exe. Even running a python script where I set os.environ is not working.
    I have the feeling that the command is executed but that the variable is not remembered for the next executable.

    Hello Martin,
    Thanks for your input. I have tried what you suggested but it didn't work. I will post my source code. Perhaps I'm doing something wrong. After setting my variable portnumber, I would normally run a query. Instead of running the query, I'm writing out the environment variables. Unfortunately, portnumber is not in the list . I also tried using "setx" insetad of "cmd.exe set" but without any difference.
        public var portnumber;
        public function run_query():void
            var file:File = new File("C:/WINDOWS/System32/cmd.exe");
            var si:NativeProcessStartupInfo = new NativeProcessStartupInfo();
            si.executable = file;
            var processArgs:Vector.<String> = new Vector.<String>();
            processArgs[0] = "/C";
            processArgs[1] = "set";
            nativeProcessStartupInfo.arguments = processArgs;
            var process:NativeProcess = new NativeProcess();
            process.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, onOutputData);
            process.start(si);
        public function set_portnumber():void
            var file:File = new File("C:/WINDOWS/System32/cmd.exe");
            var si:NativeProcessStartupInfo = new NativeProcessStartupInfo();
            si.executable = file;
            var process:NativeProcess = new NativeProcess();
            process.start(si);
            process.standardInput.writeUTF("set portnumber="+portnumber+"\n")
            setTimeout(run_query, 1000);
        public function onOutputData(event:ProgressEvent):void
            var process:NativeProcess = event.target as NativeProcess;
            textReceived.text += process.standardOutput.readUTFBytes(process.standardOutput.bytesAvailable) + "\n";

Maybe you are looking for