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.
Similar Messages
-
I have family plan of 5 iphones and all them have the same apple id, the q. is how I can set each one with their own apple id? please advise...
See How to Stop Sharing an Apple ID.
(Note that I am affiliated with that site, and some pages contain ads). -
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 -
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 -
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. -
How to Set Environment Variables in Windows
Hi Guys,
You know that we can retrieve the environment variables using System.getProperty("JAVA_HOME"); like this. It is easy.
Can anyone tell me how to create an environment variable using System class or is there any alternate java API to create environment variable. Please let me know.
My requirement is that I want to create the environment variable as follows
DEV_HOME
D:/Java/DEVAre you talking about Java System properties (get and set through System.get/setProperty) or Environment Variables (read-only, get through System.getenv)?
You can set the former, not the latter (unless you start a new process through Runtime.exec(), for which you can specify a custom environment. -
How to set environment variables in WL ?
Hi,
How to set environment variables in WL ?
Thanks,
SriviHi,
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 i can set the selected item of a dropDown component from java code
Hi
Thank you for reading my post
How i can set the slected item of a DropDown component from backing beans java code ?
it is binded with a database , so one field determine its display and one other field determine its value , I want to set the selected item of this combobox
In back code i have both value and display values to use them .
can some one give me some help ?
Thanks ,See code sample 3 at http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/helloweb.html
See also, the selection components row in the table under http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/helloweb.html
It says
One way to preselect items is to call setSelectedValue(Object[]) or setSelectedValue(Object) from the prerender() method. You pass in the return values of the items that you want preselected. Be sure to verify that getSelected() returns null before setting the default options, or you will overwrite the user's selections on a post-back. -
I want to set a variable with default value and can be changed by the user
hi,
i want to set a variable with default value and can be changed by the user, so i new a variable with setting : customer exit, single value, optional, ready for input.
in my customer exit code, i set a default value, eg. 20070530
when the variable screen popup, it display the default value 20070530, i changed it to 20070529, but it doesn't work , it still display the data in 20070530, how can i solve this problem?
your help is appreciated.Liu,
As mentioned by Anil, you need to restrict your customerr Exit code to I_STEP = 1.
or.
<u>Open your Variable in change mode, in the Last Page os the Variable Maintenance you can provide default value. Note: you are doing same thing in Customer Exit. In your case no need of Customer Exit.</u>
Nagesh Ganisetti.
Assign points if it helps. -
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
Erici
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 -
Setting persitent system environment variables using java program
hai,
Iam tryng to write installation for an application,which require to set some persistent system environment variables using java program. I have tried using set command Runtime.getRuntime().exec("cmd /c set blah blah "),but this applies only to that particular DOS promt only,i presume.And this is not perisistent.please do help.
BijuThe solution I proposed worked only on Windows XP/2003.
The following solution will work on Windows NT/2000/XP/2003 with JDK 1.2+.
1- Download the [url http://www.gjt.org/download/time/java/jnireg/registry-3.1.3.zip]JNIRegistry zipped archive.
2- Open the registry-3.1.3.zip file and extract in the folder of your choice ( Eg. c:\setenv ) only the 2 first files (when sorted by path): ICE_JNIRegistry.dll and registry.jar.
You don't need to keep the folder tree in the extraction.
3- Create the following SetEnv.java file in the same folder ( Eg. c:\setenv ).
import com.ice.jni.registry.Registry;
import com.ice.jni.registry.RegistryKey;
import com.ice.jni.registry.RegStringValue;
import com.ice.jni.registry.RegistryValue;
public class SetEnv
static final String REG_HKLM_SUBKEY_NAME = "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment";
public static void main(String[] args)
throws Exception
new SetEnv().exec(args);
void exec(String[] args)
throws Exception
if (args.length != 2)
throw new IllegalArgumentException("\n\nUsage: java SetEnv {varName} {varValue}\n\n");
String varName = args[0];
String varValue = args[1];
RegistryKey key = null;
RegStringValue value;
try
key = Registry.HKEY_LOCAL_MACHINE.openSubKey(REG_HKLM_SUBKEY_NAME, RegistryKey.ACCESS_ALL);
value = new RegStringValue(key, varName, RegistryValue.REG_EXPAND_SZ);
value.setData(varValue);
key.setValue(value);
key.flushKey();
finally
try { key.closeKey(); }
catch (Exception e) {}
}4- Compile it.
javac -classpath .;registry.jar SetEnv.java
5- Run it. varName and varValue are strings of your choice.
java -classpath .;registry.jar -Djava.library.path=. SetEnv varName varValue -
(Bash) How to set a variable with text from a file? [SOLVED]
I'm having a little problem.
I have textfile with a single line of text. What I want to do is set a variable with that line of text. How do I go about doing that?
A simple var="text" wont work in this case, since the text in the file changes with another script of mine.
Thanks in advance.
Last edited by Aziere (2007-03-27 09:07:03)if you have a file with more than one line but you only want the first line you could use 'head'
VAR=`head -n 1 file`
Last edited by SiD (2007-03-27 05:58:33) -
How to Set a Variable with data from Srouce Data Store
Hello ODI Experts,
I have created a Physical & Logical Schema and a Source Data store to pickup data from a database table.
On the other hand, I have a few variable that I will pass in a web service call (ODIInvokeWebService tool).
Would yo please guide how I can set variables from my source data store.
Thanks & Regards,
AhsanHello Bos/Damodhar/ODI Experts,
Doesn't it gives me a less optimized approach picking one column per query (per variable)?
Lets say, I have to pick 35 columns from a table and put those in 35 variables...It would mean running 35 queries for fetching one record from the database table.
Doesn't it seem less performance effective (less optimized)..a little scary..any thing better that I can do to make it more optimized?
Another question, what if multiple new values have come in the DB table, since I am using Refresh Variable, would this variable have multiple values in it?
Thanks for all your help,
Ahsan
Edited by: Ahsan Asghar on 21-Jun-2011 07:46 -
How i can set dropDown item to 6th item from java code ?
Hi
Thank you for reading my post.
how i can set dropDown item to 6th item from java code ?
i have the value field of database and i can use it to set selected item of DropDown.
so : can i use value field to set the selected item ?
Thank u.Hi,
Please go through the following thread which discusses about setting teh selected item for a dropdown:
http://swforum.sun.com/jive/thread.jspa?forumID=123&threadID=50697
Hope it helps
Cheers
Giri -
How can i create messenger with java tv API on STB
deal all.
how can i create messenger with java tv API on STB.
how can Xlets communicate each other?
how?
i am interested in xlet communications with java tv.
is it impossible or not?
help all..You can create a messenger-style application using JavaTV fairly easily. JavaTV supports standard java.net, and so any IP-based connection is pretty easy to do. The hard part of the application will be text input, but people have been using cellphone keypads to send SMS messages for long enough that they're familiar with doing this. This doesn't work well for long messages, where you really need a decent keyboard, but for short SMS-type messages it's acceptable.
The biggest problem that you need to work around is the return channel. Many receivers only have a dial-up connection, ties up the phone line and potentially costs people money if they don't get free local calls. Always-on return channels (e.g. ADSL or cable modem) are still pretty uncommon, so it's something that you nee to think about. Of course, if you do have an always-on connection then this problem just goes away.
This is really one of those cases that's technically do-able, but the infrastructure may not be there to give users a good experience.
Steve.
Maybe you are looking for
-
External monitor in BootCamp?
I have just ordered a new MacBook to replace my older MacBook Pro and have heard that you cannot use an external monitor (or projector) in BootCamp with a MacBook. Actually I was pointed to an Apple doc that says you can't use external monitors with
-
How do I put a photo on to my iPod Touch from iPhoto
On my Mac Mini, running SL OSX 10.6.8, is iPhoto '09 v. 8.1.2. and iTunes v. 11.0.2. I've got an old iPod Touch 16GB running v. 2.2.1. I want to move a photo from iPhoto onto my iPod Touch, which used to be simple. However, now when I open iTunes, th
-
Changing layout at runtime, executing background job and sending mail inXLS
Hi When i execute my program in foregroung by manually changing value of s_job = 'X' in debugging mode it is sending the correct XLS file via mail with all the data , whereas when i execute my program in backgroud mode it sends incomlete XLS file vi
-
"This page cannot be displayed error"
When I attempt to use the preview site feature, I am getting a "This page cannot be displayed smate sure the web address http//### is correct" error. Last night, I tried the feature and while it showed the page it only showed an earlier preview, none
-
Secure Connection option in MDM adapter in SAP PI 7.4
Hi, We have an option for selecting secure connection in MDM sender and receiver adapter in SAP PI 7.4. Can someone tell me what roles are required for the repository user in MDM system for this secure connection? Also, does it require any certifica