Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am running Java NetBeans 6.9 jdk 6 on SUSE Linux (a newbie on linux) and I currently need to get the path of the weblogic domain of my Java application. I have read that I can directly access the environment variable by using this :

System.getenv("DOMAIN_HOME")

The problem is I couldn't find the DOMAIN_HOME environment variable (actually I have no idea on setting up the env. variable in linux). I found instructions on the internet telling me that I could set this up by setting :

Export DOMAIN_HOME = /desired_path_to_domain

Following several instructions found on the internet, I have already tried the following resolutions :

  1. I wrote this on my home's .profile : export DOMAIN_HOME=$DOMAIN_HOME:/path_to_domain

  2. I also wrote that on my home's .bashrc and on /etc/bash.bashrc

  3. I executed this on the konsole printenv ... and as expected I saw the list of all the environment variables. At first, I thought it was pointed to .profile but it wasn't. It was displaying an entirely different value from what was defined on .profile when I executed the line echo #PATH ... so I concluded that my environment variables weren't defined on .profile

The question is, where exactly is that printenv (environment variables) defined and how can I modify it to include my DOMAIN_HOME variable. Guys, I really need this. I came up posting on forums because none of the solutions above or anywhere else could solve my problem. DOMAIN_HOME remains null (even after restarting my linux server).

share|improve this question

migrated from stackoverflow.com Sep 13 '11 at 10:14

This question came from our site for professional and enthusiast programmers.

3 Answers 3

If you define

export DOMAIN_HOME=/path/to/domain

in your .bashrc in your home directory that is sufficient to define it.

After adding the changes there simply log out and log in again for the changes to take effect.

If instead you define

export DOMAIN_HOME=$DOMAIN_HOME:/path/to/domain

you are effectively saying set domain home equal to what is already there and append :/path/to/domain to the end of it. This is not what you want.

If you just type the first export command in your terminal session this value will be valid for the period of your terminal session and should be enough to test what you need.

Just remember that UNIX is a case sensitive beast, unlike Windows, so entering Export is not the same as entering export.

share|improve this answer

The command should be:

export DOMAIN_HOME=/desired/path

If I am right: no space is allowed between the variable name and the equals sign.

If the bash shell is used, then the .bashrc file should be fine, but .profile should work, too.

share|improve this answer

You can define an environment variable in any terminal like you said:

export TEST="Hello world"

If I run that command in a shell, then I can retrieve the value of the environment variable TEST on this way with $TEST:

$ echo $TEST
Hello world

If DOMAIN_HOME is null maybe you have not set it right. Notice that when runnig exportcommand you shouldn't have any space between the variable name, the = and the value.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.