Update environment variables of unix from java
i want to update DISPLAY environment variable in unix from java.
(very urgent).
Basically not possible. The environmental variables belong to a particular task, typically the shell, and your JVM process just has a copy. If you create another task (with Runtime.exec) you can specify whatever environmental variables you like but it's always the parent that supplies them to the child, not the other way arround. (export is handled internally by the shell's own task, it's not a program of it's own).
Similar Messages
-
Running Shell Commands (not Executable) in Unix from Java
What are my options to run shell commands from Java?
My goal is to change my existing shell environment variables to some new ones provided by .anotherProfile.
Using an executable from Java is not an option because it does not work i.e. ( exec(". /home/.profile") ) brings up errors.
Someone has suggested that I start a child shell with that profile and work from there, but I'm unfamiliar with that sort of syntax and programming in general.
Any good help equals duke dollars :)Well there are some possibilities. In the original thread you mentioned that you wanted the shell script to be executed to change some enviroment parameters of the shell the JVM is executing in.
If so, and you are able to rewrite the profile so you can parse it manually. Then you can change some environment setting by writing the JNI wrappers for the getenv and setenv system calls. (Check your man pages)
That will change the environment. I am just wondering what good it will do for you? What's use of sourcing the profile in a JVM? -
Setting file permisions ,group permission on Windows and unix from java
Hi
i am trying to set up file permissions through java on unix and windows operation sysyem
.I don't want to use shell scripts .
thank you for your help.HI BIJ001,
Thanks for reply.I am paling to use
1)First i am detecting operating system
2)if it is UNIX->calling unix scripts from JAVA
2)if it is WINDOWS ->calling Bat scripts.
But attrib command in windows does not support FIle Gropu permssion like unix(chmod 777 filename).
Do yoou have any experience in .bat sctipts on file permission.
Let me know .Again thank you for reply. -
Query: accessing of shared variables of Informix from JAVA
Can i access the shared variables of Informix from my java program.
Please provide links or reading stuff if anyYou can use the error-cluster to detect the end of your queue. The erroroutput of the shared variable will return a -2220 Warning, if it reads a value it has read already before. I attached a modified example and saved it for 8.2 I hope you can open it.
Attachments:
readbuffered82.zip 51 KB -
For Bash and K shell we prefix the variable name with export. I read quiet a few times about this but i didn't understand. If you could tell me why do we need to prefix export before a variable name with example will be really greatfull to me.
Is there any one???
cheers
KumareshHi Kumaresh,
why do we need to prefix export before a variable name It's likely a pathing issue, check your Linux $PATH.
Nohup split –b500m < split_pipe > /tmp/exp_tab &
nohup compress < compress_pipe > split_pipe &
nohup exp parfile=export_tab.par file=compress_pipe > exp_tab.list 2>&1 &
Here are my notes on setting Linux vars:
http://www.dba-oracle.com/t_linux_43_variables_scripts_global.htm
Hope this helps. . .
Don Burleson
Oracle Press author -
Update JDK environment variables...
Oracle 11g RAC RHEL 4 AS
I have just upgraded JDK from 1.4 to 6.0 and I wanted to know where and which environment variables need to be updated.
Thanks.Well, I have just finished upgrading my RAC database to 11g. And in the deprecated section, it is mentioned that JDK 1.4 is not supported for 11g and we must upgrade to 1.5 or 5.0. So I upgraded to 1.6 but I still get the error:
Exception in thread "main" java.lang.UnsupportedClassVersionError: oracle/ops/opsctl/OPSCTLDriver (Unsupported major.minor version 49.0)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:539)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
when I give the the srvctl stop instance command. I am thinking maybe I need to point the environment variables to the correct java version? Perhaps I need to edit the $ORACLE_HOME/bin/srvctl file?
please feel free to move this post to the RAC section if you feel necessary.
Thank you. -
Hi,
Just curious... What are the different environment variables that Java looks at, and what is the purpose for each of them?? To clarify that I'm talking about, I think some of them are JAVA_HOME, JAVAC(?), CLASSPATH, etc.
ThanksThere are three environment variables that Java generally uses:
1. PATH
2. CLASSPATH
3. JAVA_HOME
PATH is actually a windows environment variable where you specify the paths of executable files. For Java, this environment variable helps it locate java compiler, java runtimes - java, javaw and other tools in the JDK.
CLASSPATH is specific to Java; it helps Java tools find Java class files
JAVA_HOME is used by Java Applications to point to the directory where JDK is installed.
For the current status of environment variables in Windows, run a command prompt and type 'set' (without quotes) followed by enter. Windows will then list all environment variables defined. -
Extract Environment Variable from System Variables
Hi,
I want to define a custom environment variable manually and from my code I want to retrieve the value for that system variable which I have created.
Steps:
Manual Actions
1. Right Click "My Computer" >> Properties >> Advanced System Settings >> Advanced >> Environment Variables
Here I have 2 options. User Variables and System Variables.
In either of these I have to declare a variable - "Test Region" and its value as "Test1"
Now, when I run my c# program I have to get "Test1" as output when I provide "Test Region" as parameter.
Please provide me the code for this.Dear Cheong,
It is working perfect now, when I restarted the PC.
But the problem is each time when I change the Value of the environment variable, I need to restart the PC to make it effective.
Is there any solution for this?
Your support is much appreciated. -
Getting oracle environment variables using plsql code
Hi Geeks,
Can anyone tell me how to get an Oracle environment variable (eg db_cache_size) from inside a plsql block of code or through a sql query?
Thanks,
PrabhuIs it possible to update the values via SQL?That's indicated by:
ISSES_MODIFIABLE VARCHAR2(5) Indicates whether the parameter can be changed with ALTER SESSION (TRUE) or not (FALSE)
ISSYS_MODIFIABLE VARCHAR2(9) Indicates whether the parameter can be changed with ALTER SYSTEM and when the change takes effect:
See the docs:
http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/dynviews_2012.htm#REFRN30176 -
Need advice on Environment variables for DAC
Hi,
I have made the following changes to DAC_ENV.sh file in DAC folder.
export PATH=$PATH:c:/Informatica/PowerCenter8.1.1/server/bin:c:/Informatica/PowerCenter8.1.1/server:.
export PM_HOME=c:/Informatica/PowerCenter8.1.1/server
export INFA_DOMAINS_FILE=c:/Informatica/PowerCenter8.1.1/domains.infa
export PM_REPHOME=c:/Informatica/PowerCenter8.1.1/server/bin
Later executed, . ./config.sh and noticed pmcmd is not getting invoked.
Once i changed, PM_HOME to c:/Informatica/PowerCenter8.1.1/server/bin, pmcmd is getting invoked properly.
But, i shouldn't specify 'INFA_HOME/server/bin' for PM_HOME as per the documentation, but somehow i was getting errors when i followed the instructions.
Please let me know if it causes any issues going forward.
Our version is, OBI 10.1.3.3.3
Thanks,
Raghu
Message was edited by:
Raghu KYes. I found the instructions confusing too.
The docs
Oracle® Business Intelligence Applications Installation Guide for Informatica PowerCenter Users Version 7.9.5.1 Part Number E13765-01
Chapter 4 Installing and Setting Up Oracle BI Applications
Configuring the DAC Server
Enabling DAC Server Communication with Informatica PowerCenter
How to Verify the DAC Server Is Able to Use pmrep and pmcmd
How to Set Environment Variables on UNIX or Linux
says change from
export PM_HOME=%INFORMATICA_SERVER_LOCATION%
to
export PM_HOME=/home/Informatica/PowerCenter8.1.1/server
The actual file from the install of BIApps 7.9.5.1 cotains INFA_HOME not PM_HOME
#Note1: %INFORMATICA_SERVER_LOCATION% denotes location of
# Informatica PowerCenter Services installation.
# Example: /home/Informatica/PowerCenter8.1.1/server
export INFA_HOME=%INFORMATICA_SERVER_LOCATION%
But, in any case, by following these instructions the environment is not set correctly
pmrep/pmcmd both throw
FATAL ERROR during initialization: Error initializing /data/app/oracle/product/10.1.3/bi_2/oraclebi/DAC/pmlocale.bin. Make sure the environment variable INFA_HOME is defined and set to where Informatica products are installed. Application terminated.
A fix is to set INFA_HOME and not PM_HOME to the root of the home for informatica
For example
*/home/Informatica/PowerCenter8.1.1*
- not /home/Informatica/PowerCenter8.1.1/*server*,
- not /home/Informatica/PowerCenter8.1.1/server/*bin*
Now when you test pmcmd and pmrep it works :)
For example,
$ cat dac_env.sh | grep INFA_HOME
export INFA_HOME=/data/app/oracle/product/8.1.1/informaticapowercenter_1
$ . ./config.sh
$ echo $PM_HOME
$ echo $INFA_HOME
/data/app/oracle/product/8.1.1/informaticapowercenter_1
$ pmcmd
Informatica(r) PMCMD, version [8.1.1 SP5], build [186.0822], LINUX 32-bit
Copyright (c) Informatica Corporation 1994 - 2008
All Rights Reserved.
Invoked at Tue Mar 17 14:18:04 2009
pmcmd> exit
$ pmrep
Informatica(r) PMREP, version [8.1.1 SP5], build [186.0822], LINUX 32-bit
Copyright (c) Informatica Corporation 1994 - 2008
All Rights Reserved.
This Software may be protected by U.S. Patent Numbers 6,208,990; 6,044,374; 6,014,670; 6,032,158; 5,794,246; 6,339,775, 6,850,947; 6,895,471, and other U.S. Patents Pending.
Invoked at Tue Mar 17 14:18:09 2009
pmrep>exit -
Java and UNIX environment variables
Hi folks,
am I right when I say that it is not possible to access UNIX environment variables from Java (these ones delared by the export statement)?
Cheers,
HeikoYes.. Since some OS do not have the concept of environment variables,it is directly not possible.
But using the method System.getProperties you can get
some inf about the environment.
the following links may be of some help to you
http://www.javaworld.com/javaworld/javaqa/2001-07/01-qa-0706-env.html
http://www.jguru.com/faq/view.jsp?EID=11422 -
Setting windows environment variables from Java program
Is there any way to set environment variables from Java program in Windows? Any help is appreciated.
Here is my situation:
I need to decrypt an encrypted Oracle user password in a batch file which will be used while running a sql script with sqlplus. I was planning to have bat file which will call a Java program decrypt the password and set it as an env variable in windows which will be available while calling sqlplus.
thanksRuntime.exec has a lot of overloadings. Two of them
allows you to specify the environment variables.
exec
public Process exec(String[] cmdarray,
String[] envp,
File dir)
throws IOExceptionExecutes the specified command and
arguments in a separate process with the specified
environment and working directory.
cmdarray - array containing the command to call and
its arguments.
envp - array of strings, each element of which has
environment variable settings in format name=value.
dir - the working directory of the subprocess, or null
if the subprocess should inherit the working directory
of the current process.
I had this sample program:
public class SetVarExample {
public static void main (String[] args) throws Exception {
String[] cmd_env= new String[] {"password="+"ABCD","Path=C:\\Sun\\AppServer\\jdk\\bin"};
String cmd = "cmd /c SET ";
Runtime.getRuntime().exec(cmd,cmd_env);
System.out.println( "Finish ...." );
I tried it in a command prompt. But looks like when the program exits, it's a whole new process and so it does not retain the env variables set in the java program.
Any suggestions? Am I doing it worng?
thanks -
How do i get value of Environment variables from a java program?
Hai,
I have a setup file wherein i set the path for the root directory , in the following way.
setenv TPEROOT "/home/systpe/khurram/changes"
when i give echo $TPEROOT
the path , home/systpe/khurram/changes , is displayed on the console
If i want to assign the $TPEROOT to a string variable str in my java program , then how can i do it.
I want to use the value of the environment variable in my program.
Any help in this regard would be very useful
Thanks
khurramjava -DTPEROOT=$TPEROOT myőackage.myclass myargs
-
Unable to access value in System Environment Variable using Java
I am using Java code to get the value of a System Environment Variable using the Runtime, Process java classes.
The code works fine in tomcat, but when deployed in 9ias the code is unable to retrieve the value stored in the System environment variable in Windows 2000.Thanks for the comment steve, here is the code which i am using.
public String getEnvironmentVariable()
// This will get the FEDREP_HOME environment variable
String FEDREP_HOME = null;
Process p = null;
Runtime rt = Runtime.getRuntime();
try {
// invokes a shell-command to retrieve FEDREP_HOME variable
String OS = System.getProperty("os.name").toLowerCase();
// Get the Windows 95 environment variable
if (OS.indexOf("windows 9") > -1)
p = rt.exec( "command.com /c echo %FEDREP_HOME%" );
// Get the Windows NT environment variable
else if (OS.indexOf("nt") > -1)
p = rt.exec( "cmd.exe /c echo %FEDREP_HOME%" );
// Get the Windows 2000 environment variable
else if (OS.indexOf("2000") > -1)
p = rt.exec( "cmd.exe /c echo %FEDREP_HOME%" );
// Get the Windows XP environment variable
else if (OS.indexOf("xp") > -1)
p = rt.exec( "cmd.exe /c echo %FEDREP_HOME%" );
// Get the unix environment variable
else if (OS.indexOf("linux") > -1)
p = rt.exec( "sh -c echo $FEDREP_HOME" );
// Get the unix environment variable
else if (OS.indexOf("unix") > -1)
p = rt.exec( "sh -c echo $FEDREP_HOME" );
// Get the unix environment variable
else if (OS.indexOf("sunos") > -1)
p = rt.exec( "sh -c echo $FEDREP_HOME" );
} else
System.out.println("OS not known: " + OS);
// set up to read subprogram output
InputStream is = p.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
// read output from subprogram
FEDREP_HOME = br.readLine();
br.close();
} catch(Exception ex)
System.out.println("Error when getting FEDREP_HOME environment variable");
ex.printStackTrace();
return(FEDREP_HOME); -
UNIX "export" Command from Java
Hi,
Am facing a problem while exeuting UNIX command from java. Am attaching the code which I am trying to execute.
import java.io.*;
public class RunCommandExample {
public static void main(String args[]) {
String s = null;
try
Runtime.getRuntime().exec("password=midware1");
//p = Runtime.getRuntime().exec("export password");
System.exit(0);
catch (IOException e)
System.out.println("[IOException]. Printing Stack Trace");
e.printStackTrace();
System.exit(-1);
}This gives me the following error.
[IOException]. Printing Stack Trace
java.io.IOException: password=midware1: not found
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:52)
at java.lang.Runtime.execInternal(Native Method)
at java.lang.Runtime.exec(Runtime.java:566)
at java.lang.Runtime.exec(Runtime.java:428)
at java.lang.Runtime.exec(Runtime.java:364)
at java.lang.Runtime.exec(Runtime.java:326)
at RunCommandExample.main(RunCommandExample.java:24)
Please let me know the solution for this problem.
Waiting for your valuable replay..
Thanks in advance,
Ashly.Assigning and exporting variables are not commands that you can execute from Java. You can only execute programs--binary executables. Assigning and exporting shell or environment variables is part of the shell.
Why are you trying to do this? Even if you could, it wouldn't affect the running VM, and it wouldn't affect anything outside that exec() invocation.
If you need to set them for something else you're going to run, then you should set them in a shell script and run that script.
Maybe you are looking for
-
Extra expenses (dunning and bank costs ...) on Payments
Hello, I ask you how to manage the extra expenses (for examples for dunning and banks costs) on incoming payments and outgoing payments. I tried to increase the amount of payment but it is not possible. It is possible only to make a manual journal en
-
RMAN full database restoration
Hi All, I'm doing a test of rman backup. I took full backup of my database (controle file, datafiles and archivelog file). I dropped my database from dbca GUI. Can i restore my full backup from RMAN in this case. I mean i want to restore my full back
-
After adding info to the metadata, such as city, sublocation, state, description, I have to enter all the same data to an MSwroks database that i then import into MSAccess. I thought maybe there was some way to just transfer data with the same field
-
The software update failed !!Help Please
Hi every one. I tried to update my xpria z1. it downloaded software but installing has failed. I can not use PCC because when I connect my phone,PCC does not work properly. When I connect it to wall sharger , it constantly powering on and powering of
-
450 g2 Wireless Card upgrade and antennas
Hello, I just ordered a ProBook 450 G2, model # L8D98UT. It comes with the Intel 3160 AC Wireless card. I'd like to upgrade this to the 7260 AC Card. Is this possible, and does this specific model come with the 2 antenanas required for the 7260 Wi