wood burning stoves 2.0*
The moose likes Linux / UNIX and the fly likes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark ""root" vs. "user defined user"" Watch ""root" vs. "user defined user"" New topic
Author

"root" vs. "user defined user"

Unnsse Khan
Ranch Hand

Joined: Nov 12, 2001
Posts: 511
Ok. I downloaded and installed the JDK 1.4.0_01 in /usr/java/j2sdk1.4.0_01
I, then, under my /root directory, I edited the .bash_profile which now displays this:
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc]; then
.~/.bashrc
fi
# User specific environment and startup programs
JAVA_HOME=$JAVA_HOME:/usr/java/j2sdk1.4.0_01
CLASSPATH=$CLASSPATH:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/jre/lib/rt.jar
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
BASH_ENV=$HOME/.bashrc
USERNAME="root"
export USERNAME BASH_ENV PATH JAVA_HOME CLASSPATH
Now, here is my situation:
When I log-in to Linux using "root" and activate the command prompt, and type:
$ java -version
It works! But I heard that other than for installing software, one should always create a profile and not use "root" too much (because of the imminent danger of human error), so I created a user by the name of "untz". When I logged into Linux as "untz" and wrote a simple Java Applet, it didn't recognize the:
$ javac -verbose ButtonApplet.java
It didn't recognize the "javac" command! If anyone can help me with this, I would appreciate it, because I am yearning to start all of my future development on Linux, and don't really want to use "root" too much as the user. Also, if anyone sees any errors (in my .bash_profile), I would appreciate it if they can inform me.
Thanks again,
Unnsse
Unnsse Khan
Ranch Hand

Joined: Nov 12, 2001
Posts: 511
It seems that for permissions set for the PATH environmental variable, it only always the "root" user to use commands from $JAVA_HOME/bin, and other "users" aren't allowed... Can anyone help me in alleviating this problem? BTW, I am using Red Hat 7.3
Unnsse Khan
Ranch Hand

Joined: Nov 12, 2001
Posts: 511
Hello...
OK, I found a .bash_profile in the /home/untz directory... I added the JAVA_HOME and CLASSPATH environmental variables... I also added $JAVA_HOME/bin to the PATH environmental variable.
After I saved and exited the file (.bash_profile located in /home/untz), I ran it using:
source .bash_profile
It then worked when I typed in:
$ java -version
Now, the problem is, I close the command prompt in Linux or if log back in as "untz" and type "java -version" it still doesn't recognize "java" from PATH. I have to use: source .bash_profile, each time I log-in as "untz". Can anyone help me with this?
Unnsse Khan
Ranch Hand

Joined: Nov 12, 2001
Posts: 511
Can someone please help me with this? I think that I put an inadequate subject heading and that's why no one wants to read this?
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
I guess there's a few reasons why nobody has replied to this yet.
First, on the forum list it looks like you have lots of replies! It's only when you look inside you find that they are all from yourself.
Second, I was going to reply, but I saw that you have discovered what was going to say yourself, anyway.
Third, at that point it becomes a puzzling question, and we really need to know more about how your system is set up to find out why this doesn't work for you. For most people, simply modifying the user's startup file makes everything work, so there must be something else different in your system.
On that basis, here are a few questions:
1. Are you sure that your user is actually running bash when you login? Linux systems typically have several shells available, and although bash is usually the default, you could easily be running another one, which would ignore your .bash_profile in favour of its own startup file.
2. What are the file permissions of your .bash_profile ? which user "owns" it ?
3. Is anything alse running after your new settings when you log in and which which resets the PATH to something else? (.bashrc, for example?)


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Gabriel Cane
Ranch Hand

Joined: Mar 27, 2001
Posts: 39
1) Log in as root
2) edit /etc/profile
3) add your variables, as well as setting your classpath and path variable to include your JDK stuff
4) save the changes.
5) log out completely
6) log back in
It should work /etc/profile sets environmental variables for ALL USERS.


Sun Certified Programmer for the Java 2 Platform
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: "root" vs. "user defined user"
 
Similar Threads
Problem with installing JUnit on Red Hat
confuse on how to set the java_home classpath correctly
Having some problem with redhat installation
MySQL Driver, Help!
JUnit 3.8.1 on Red Hat 7.3