Linux: how to set JAVA_HOME in startup script?

My Linux box cannot find JDK classpath.
How do I set CLASSPATH and JAVA_HOME in a script file that is loaded at startup?
Thanks!

What are you trying to do? If you are executing a script that runs a java process in cron, or something, then simpl place these lines in that script before the call to java.
All environment variables are set when the shell starts. Every process is run under a shell, and that shell is what has the environment variables. Which environment variables it has, depends on which shell is started, and how that shell is started.
Cron, and some users, have a very limited shell environment. Even these shell environments are configurable though. How this is done, however, is not a topic for this forum.

Similar Messages

  • How to set JAVA_HOME in solaris9

    hello all,
    Do some one give me some url's or information how to set JAVA_HOME, CLASSPATH and related environmental setting for SOLARIS 9 operating system.
    thanQ,
    Han.

    solaris is the unix-like OS
    so try to find the same info about linux, freebsd or other unix os
    in general try export or set command

  • How to set page numbers in scripts

    Hi,
        i want page numbers at bottom of page,
      please tell me how to set page numbers in scripts?

    Hi,
    In footer
    use this
    &PAGE& / &SAPSCRIPT-FORMPAGES&
    &PAGE& of &SAPSCRIPT-FORMPAGES&
    reward if it helps..
    regards,
    Omkar.

  • How to set the JVM Startup Options?

    Hi,
    I want to know how to set the JVM Startup Options...
    The idea is, I want to test how the remote clients can access an EJB that is running on a different machine... Remote client here means, I have a java client application that runs on one machine and that contacts an EJB thats running on a different machine... I posted this question in J2EE forum and I got this reply...
    If you need to access EJB components that are residing in a remote system other than the system where the application client is being developed, set the values for the Java Virtual Machine startup options:
    jvmarg value = "-Dorg.omg.CORBA.ORBInitialHost=${ORBhost}"
    jvmarg value = "-Dorg.omg.CORBA.ORBInitialPort=${ORBport}"
    Now how to set the JVM Startup Options? I know my server ORBHost Name and the ORBPort..
    Anybody to help !!!
    Thanks in advance,
    Karthik

    java -Dorg.omg.CORBA.ORBInitialHost=${ORBhost} -Dorg.omg.CORBA.ORBInitialPort=${ORBport} <the main class>
    That should do it..

  • How to set JAVA_HOME in REDHAT 9.0 Linux?

    I was trying to set JAVA_HOME in profile file, but unable to decide where to put the java_home path. Can anyone guide me?
    J2sdk and JRE are in /USR/JAVA

    It is sufficient to set PATH.
    In Unix (including Linux) most file systems are case-sensitive regarding the file and directory names. So /USR/JAVA is different from /usr/java.

  • How to set JAVA_HOME programatically

    Hi Friends,
    Is there anyway to set JAVA_HOME environment property using a batch script.Actually,I am trying to check if the user system has java installed or not. If not,I make him run the JRE installer but the problem is when I try to start Tomcat, it expects JAVA_HOME to be set. So, I want to set JAVA_HOME programatically, is there anyway to do so???
    This is the script i am using to check if java is already installed or not:
    @echo off
    ::This batch file only tested under Windows 2000
    ::It will detect the short path of the current version
    ::of the Java runtime executable
    ::First test to see if we are on NT or similar OS by seeing
    ::if the ampersand is interpreted as a command separator
    reg1.txt echo 1234&remtype reg1.txt | find "rem"
    if not errorlevel 1 goto WIN9X
    ::Find the current (most recent) Java version
    start /w regedit /e reg1.txt "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment"
    type reg1.txt | find "CurrentVersion" > reg2.txt
    if errorlevel 1 goto ERROR
    for /f "tokens=2 delims==" %%x in (reg2.txt) do set JavaTemp=%%~x
    if errorlevel 1 goto ERROR
    echo Java Version = %JavaTemp%
    del reg1.txt
    del reg2.txt
    ::Get the home directory of the most recent Java
    start /w regedit /e reg1.txt "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\%JavaTemp%"
    type reg1.txt | find "JavaHome" > reg2.txt
    if errorlevel 1 goto ERROR
    for /f "tokens=2 delims==" %%x in (reg2.txt) do set JavaTemp=%%~x
    if errorlevel 1 goto ERROR
    echo Java home path (per registry) = %JavaTemp%
    del reg1.txt
    del reg2.txt
    ::Convert double backslashes to single backslashes
    set JavaHome=
    :WHILE
      if "%JavaTemp%"=="" goto WEND
      if not "%JavaHome%"=="" set JavaHome=%JavaHome%\
      for /f "delims=\" %%x in ("%JavaTemp%") do set JavaHome=%JavaHome%%%x
      for /f "tokens=1,* delims=\" %%x in ("%JavaTemp%") do set JavaTemp=%%y
      goto WHILE
    :WEND
    set JavaTemp=
    echo Java home path (long, with spaces) = %JavaHome%
    ::Convert long path (with spaces) into a short path
    for %%x in ("%JavaHome%") do set JavaHome=%%~dpsx
    echo Java home path (short path, no spaces) = %JavaHome%
    ::Test the java path to see if there really is a java.exe
    if not exist %JavaHome%\bin\java.exe goto ERROR
    ::Make changes to the PATH
    echo Insert code here that needs to know the short path to Java.
    set path=%JavaHome%\bin;%path%
    goto DONE
    :WIN9X
    echo Insert code here for Windows 9x
    goto DONE
    :ERROR
    echo Insert code here for conditions where Java.exe can't be found
    goto DONE
    :DONEThanks

    You are asking questions about Windows batch scripting in a Java forum?
    When you get right down to it, the question is "How do I set an environment variable in a batch script", isn't it? Free your mind from useless distractions: the batch script and the operating system don't care at all what you're going to use that environment variable for.
    Oh yeah, I almost forgot: you use the SET command to set an environment variable.

  • How to set volume using Powershell script?

    I would like to know on how to set volume under Window 7 Home 64 bits system using Powershell script.
    Such as 8000 levels as default
    Does anyone have any suggestions?
    Thanks in advance for any suggestions
    Thanks in advance for any suggestions

    Try this.
    Function Set-SpeakerVolume{
    Param (
    [switch]$min,
    [switch]$max,
    [int]$Percent
    $wshShell = new-object -com wscript.shell
    If ($min){
    1..50 | % {$wshShell.SendKeys([char]174)}
    ElseIf ($max){
    1..50 | % {$wshShell.SendKeys([char]175)}
    elseif($Percent){
    1..50 | % {$wshShell.SendKeys([char]174)}
    1..($Percent/2) |% {$wshShell.SendKeys([char]175)}
    Else{
    $wshShell.SendKeys([char]173)
    This works in Windows 8.1.
    Stolen / Modified from
    http://blogs.technet.com/b/heyscriptingguy/archive/2013/07/28/weekend-scripter-cheesy-script-to-set-speaker-volume.aspx, which took me 20 seconds of (apparently) lucky searching.
    Karl
    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer.
    My Blog: Unlock PowerShell
    My Book:
    Windows PowerShell 2.0 Bible
    My E-mail: -join ('6F6C646B61726C406F75746C6F6F6B2E636F6D'-split'(?<=\G.{2})'|%{if($_){[char][int]"0x$_"}})

  • Firefox 4 multi user environment in linux: How to set global settings?

    <blockquote>Locking duplicate thread.<br>
    Please continue here: [/questions/826921]</blockquote><br>
    Hi,
    We used to be able to change settings in all.js file in FF 3.x.x platform, for changing settings like, proxy, authentication, etc. We installed FF 4.0.1 in linux, but, I can't find the all.js file to change any of the global settings in FF 4.0.1.
    Could you please point me how to changeglobal settings in FF 4.x version?
    thanks in advance.

    Hi. A JDBC connection pool is a set of identical, interchangeable, pre-made
    connections, and the controls to make sure only one user uses a particular
    connection at any one time. If you want to have different DBMS users, you can
    have a separate pool for each DBMS user, which may contain as many or few
    connections as you want. Some applications has a pool for the accounting
    applications, and another for the sales applications etc. Some do have a
    separate pool for john, jane, joe etc, each with one connection. Pools
    can be created and destroyed dynamically using the dynamic pool API.
    Joe
    softstar wrote:
    >
    Hi all,
    I need to know how to set Multi User Environment in the weblogic 5.1
    properties file..
    Here my question is..:)
    1) I have a database with multiple users and having different privileges
    for the users.. and i need to use all the privileges when user aceess
    the database through weblogic server connectionPool.
    2)According to the user privileges i need access the database tables
    content and gives the frontEnd(jsp).
    3)How to modify dynamically weblogic.properties file in the weblogic
    5.1.
    If anybody having idea reg. this issues pl...help me..
    Thanks in advance
    Chandu([email protected],[email protected])

  • How to set JAVA_HOME

    Hi,
    can any body tell how to set the JAVA_HOME variable for the
    windows 95/98 operating system. Iam using the "jakarta-tomcat-3.2.1"
    server for running the jsp files. I could do it in window NT os by setting up in the environment option of the mycomputer properties. I
    couldn't know how to set it in the window 95/98 os
    phani

    To set the JAVA_HOME variable in Windows 95/98 you have to edit the file autoexec.bat located on your hard drive and add a line similar to this one.
    SET JAVA_HOME=C:\J2SDK1.4.1
    Where c:\j2sdk1.4.1 is the directory where java is installed.
    Hope this helps.

  • How to set JAVA_HOME and ANT_HOME in OSX 10.9.5

    Hi
    recently we moved to 10.9.5 and i dnt see .profile file at home. can you please let me know how to set up JAVA_HOME and ANT_HOME
    when ever i set those at termanil with export commands . those are getting vanished after closing the terminal. pls let me know how to set up PATHs at 10.9.5.
    since i dnt see the profile file.
    Thanks
    Pasunoori

    Modify .bash_profile.

  • How to set multi select by script to a list box.

    Hi All,
    I have a list box with multiple select on the form with list (Say A,B,C,D,E,F,G ..)
    When I select A,C,E ans say this.RawValue I get A,C,E separated by carrage returns.
    When i submit the form in my Fm I get A#C#E its all fine.
    Now when the form is openend for the 2nd time to update values I get the value as A,C,E separated by carrage return thats fine too.
    Now i need to set these 3 values as selected by default so i had some java script in form ready.
    Where i iterate tru these list match the entries in the dropdown its fine untill here.
    this.setItemState(index,true)
    is the code to set them as selected but when i do only the 1st found is set to selected not the remaining ones.
    Am i doing something wrong here, please let me know with your suggestions.
    below is my script.
    var ddValue =  this.rawValue;
    ddValue = ddValue.replace("#","\n");
    var ddArray = ddValue.split("\n");
    var ddLen = ddArray.length;
    var textValue = "";
    GM_INTAKE_STRUCTURE.sf80.sfItemBuilder.sfHeaderConditions.dlExpenseType.clearItems;
    GM_INTAKE_STRUCTURE.sf80.sfRequestSummary.dlItem.clearItems;
    for(var i = 0;i<ddLen;i++){
         for(var j = 0;j<this.length;j++){
              if(this.getSaveItem(j) == ddArray<i>){
                   this.setItemState(j,true);                
                   GM_INTAKE_STRUCTURE.sf80.sfItemBuilder.sfHeaderConditions.dlExpenseType.addItem(this.items.nodes.item(j).value,this.getSaveItem(j));
    Thanks & Regards,
    Sai

    Hi Sai,
         The replace function is only replacing the first occur of #, not all of them. But you don't even need to replace the # before you do the split, just change your first lines to split directly with the # character. Your code should look as follow:
    var ddValue =  this.rawValue;
    var ddArray = ddValue.split("#");
    var ddLen = ddArray.length;
    var textValue = "";
    GM_INTAKE_STRUCTURE.sf80.sfItemBuilder.sfHeaderConditions.dlExpenseType.clearItems;
    GM_INTAKE_STRUCTURE.sf80.sfRequestSummary.dlItem.clearItems;
    for(var i = 0;i<ddLen;i++){
         for(var j = 0;j<this.length;j++){
              if(this.getSaveItem(j) == ddArray<i>){
                   this.setItemState(j,true);                
    GM_INTAKE_STRUCTURE.sf80.sfItemBuilder.sfHeaderConditions.dlExpenseType.addItem(this.items.nodes.item(j).value,this.getSaveItem(j));
    Best regards, Aldo.
    Any comments and feedback are welcome.

  • How to set Business Hours with script?

    I have a single SCCM 2012 SP1 CU4 server running on Windows Server 2012.
    My business has multiple locations and some of them have different hours of operation.  I am wanting to change the "Business Hours" for some of these sites and looking for the best way to do it.
    I found this guide that uses PowerShell, but I get a "Script is not signed" error:
    http://powersheller.wordpress.com/2012/11/20/sccm-2012-setting-software-center-business-hours-with-a-compliance-configuration-item/
    I saw Torsten's example using a VBscript, but I get an "Incorrect function" error:
    http://www.mssccmfaq.de/2012/03/26/software-center-business-hours-auslesen-setzen/
    Both of those web pages look like they were done a couple years ago so I hope everything still applies.
    Any help would be great!
    Thanks

    For the Powershell one... make sure you have two things. In the ConfigItem, for the Compliance test, you did check the box about "run the specified remediate script ..." right?
    for the Baseline, when you assigned it, you did check the box about remediate when you deployed it to the collection?
    If either or both of those are missing, what you are doing is monitor only... so the remediation script won't ever actually run, so it's monitoring only.  So it would make sense that you are getting non-compliants back.  You aren't ever asking
    it to really run the remediation piece.
    EDIT:  Just referencing this here... just in case: 
    http://blogs.technet.com/b/server-cloud/archive/2012/03/28/business-hours-vs-maintenance-windows-with-system-center-2012-configuration-manager.aspx  Sometimes people misunderstand what a business hours definition means vs. what a Maintenance Window
    (Service Window) means in Configmgr 2012.  If you aren't 100% positive what the difference is, read through that blog just to get it straight.
    Standardize. Simplify. Automate.

  • How to set "ErrorDestination" in Ant script

              Hi,
              I try to set the "ErrorDestination" attribute for a JMS Queue, by pointing to
              another previously created JMS Queue:
              <create type="JMSQueue" name="UploadErrorQueue" property="myqueue">
              <set attribute="JNDIName" value="aaa.jms.UploadErrorQueue"/>
              </create>
              <create type="JMSQueue" name="Upload Queue">
              <set attribute="JNDIName" value="aaa.jms.UploadQueue"/>
              <set attribute="ErrorDestination" value="${myqueue}"/
              </create>
              However, this does not work, I get an error saying that both JMS Queues must resided
              in the same Server, but this is the case, so I don'y get it?
              Any ideas?
              Kind regards,
              Laurent.
              

              Hi Laurent,
              you can use that queuename as a token and replace that token with the ant script.
              Lucky
              "Laurent" <[email protected]> wrote:
              >
              >Hi,
              >
              >I try to set the "ErrorDestination" attribute for a JMS Queue, by pointing
              >to
              >another previously created JMS Queue:
              >
              ><create type="JMSQueue" name="UploadErrorQueue" property="myqueue">
              > <set attribute="JNDIName" value="aaa.jms.UploadErrorQueue"/>
              ></create>
              >
              ><create type="JMSQueue" name="Upload Queue">
              > <set attribute="JNDIName" value="aaa.jms.UploadQueue"/>
              > <set attribute="ErrorDestination" value="${myqueue}"/
              ></create>
              >
              >However, this does not work, I get an error saying that both JMS Queues
              >must resided
              >in the same Server, but this is the case, so I don'y get it?
              >
              >Any ideas?
              >
              >Kind regards,
              >Laurent.
              >
              

  • How to set PATH at startup

    Hello,
    I'm using pam_pkcs11 but some libraries cannot be loaded. I logs the PATH and LD_LIBRARY_PATH variables.
    LD_LIBRARY_PATH does not exist.
    Here is syslog traces :
    Apr 19 14:34:42 unknown dtlogin[1790]: [ID 702911 user.info] PATH /usr/sbin:/usr/bin
    Apr 19 14:34:42 unknown dtlogin[1790]: [ID 702911 user.info] Using config file /etc/pam_pkcs11/pam_pkcs11.conf
    Apr 19 14:40:38 unknown dtlogin[1790]: [ID 598382 user.error] load_pkcs11_module() failed loading /opt/Company/Soft/lib/libmypkcs11.so: dlopen() failed: ld.so.1: dtlogin: fatal: libstdc++.so.6: open failed: No such file or directory
    libstdc++.so.6 is in /usr/local/lib. After login, this path is in LD_LIBRARY_PATH.
    I don't know where is the PATH definition (before login) !
    I tried modifing /etc/profile, /etc/init.d/dtlogin.sh files without success.
    Could you help me, please ?
    Aidev

    You crossposted this same question to at least one other forum web site:
    http://www.linuxquestions.org/questions/solaris-opensolaris-20/default-path-before-login-875872/
    You didn't mention that anywhere (at either site).
    That is considered rude forum etiquette.
    Where would you want your answer?
    (A partial sentence here and a partial sentence elsewhere?)
    Why should anyone spend their time to answer you when it might a duplicate of what you've already been told?
    Be more considerate in the future and ALWAYS mention where you might be researching your inquiries.

  • Powershell startup scripts fail on Windows 8.1 with error 267

    GPO Powershell startup script fails to execute on Windows 8.1, but does run on Windows 8 and Windows 7. Powershell logon scripts run normally on all versions of Windows.
    The event log contains entries with event ID 1130 from the GroupPolicy source. The log entries claim error 267 "directory name is invalid".
    Running cmd.exe on Windows 8.1 under the computer's account (NT Authority\SYSTEM) confirms that the Powershell script's path in SYSVOL is valid and the script executes normally.
    Running procmon on Windows 8.1 while the startup script is being run on a computer shows that the computer caches the files and folders for this GPO into C:\Windows\system32\GroupPolicy.
    I am not sure why these scripts are failing to execute on Windows 8.1 when they run on Windows 8 and the same set of GPOs are applied to both Windows 8.1 and Windows 8 computers.

    These are all good suggestions, but I have already tried to eliminate:
    All environment variables
    All network paths
    Setup the GPO to reference the script by the file name and with a full absolute path. Neither worked.
    Tried copying the scripts to multiple folders inside the policy, since the event log message reports only the root path of the policy.
    I also used procmon to monitor how the computer handles the startup scripts. I found that the computer caches them into a folder under C:\Windows\System32, but never runs any of them. I never found an error that I could correlate with the event log.
    For instance the following one line scripts failed to run:
    'I AM HERE.' | sc -path C:\Windows\TEMP\TEST.txt
    write-host 'I AM HERE.'
    As far as I can see the first script relies on the existence of C:\Windows\TEMP and write permission to it, which SYSTEM should have.
    The second one liner has no dependencies at all and it doesn't run with the same error.
    I have created multiple GPOs and scripts, so if there was a problem in creating these files and folders it is happening over and over. I checked the permissions and computer accounts have read and execute permissions all throughout the GPOs.
    Everything works perfectly on Windows 7 and 8, just not on 8.1.

Maybe you are looking for