This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
I downloaded the j2sdk-1_4_0-linux-i386-rpm.bin and than I did the following: 1. make file executable # chmod +x j2sdk-1_4_0-linux-i386-rpm.bin 2. run executable # j2sdk-1_4_0-linux-i386-rpm.bin 3. install rpm created # rpm -ivh j2sdk-1_4_0-fcs-linux-i386.rpm 4. add java "bin" path to PATH variable by adding line to file "/etc/profile" PATH=/usr/java/j2sdk1.4.0/bin:$PATH
Here is part of the profile file:
# /etc/profile # System wide environment and startup programs, for login setup # Functions and aliases go in /etc/bashrc
PATH=/usr/java/j2sdk1.4.0/bin:$PATH pathmunge () { if ! echo $PATH | /bin/egrep -q "(^| $1($| " ; then if [ "$2" = "after" ] ; then PATH=$PATH:$1 else PATH=$1:$PATH fi fi }
What I did wrong I cannot understand? when I do: javac Mike.java .. I got the error message bash: javac: command not found which java /usr/bin/which: no java in (/usr/local/sbin:/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin:/usr/local/bin:/root/bin) Please advice... Thanks
you need to edit the classpath for all users... not just root. you probably just edited root's classpath...
what?
Mike Shn
Ranch Hand
Joined: May 26, 2001
Posts: 149
posted
0
When I setup the path I logged as a root and modify the file /etc/profile. What file I need to modify that all users can compile the Java programs. Thanks
Greg Harris
Ranch Hand
Joined: Apr 12, 2001
Posts: 1012
posted
0
on my Redhat 7.2 machine i edit the ~/.bash_profile file for each user. what distribution of linux are you running? [ May 21, 2002: Message edited by: Greg Harris ]
Mike Shn
Ranch Hand
Joined: May 26, 2001
Posts: 149
posted
0
Red Hat 7.3
Greg Harris
Ranch Hand
Joined: Apr 12, 2001
Posts: 1012
posted
0
okay, maybe i can help... login with your normal username and give the following command in a terminal window: pico ~/.bash_profile that will open your profile file in the terminal window. add your classpath and path to the file, save the file and reboot to make the changes take effect.
Mike Shn
Ranch Hand
Joined: May 26, 2001
Posts: 149
posted
0
Does it possible to modify 1 file as a root and all users can use JDK? Or I have to modify for each user separetly.
I'd like to know how to do this as well - I'm pretty sure that on the old Unix systems like SCO and AIX that I used to use, you could edit the /etc/.profile and all users would process it before processing their own .profile. This might have been something we scripted ourselves though. How would you call a central .profile from the user's .bash_profile?
I have seen things you people would not believe, attack ships on fire off the shoulder of Orion, c-beams sparkling in the dark near the Tennhauser Gate. All these moments will be lost in time, like tears in the rain.
/etc/profile (note, no ',') is processed before any of the other files for all Linux versions that I'm aware of. What is probably happening is that somewhere after you set up your path, something else is doing a direct assignment, without including the previous value, so it is getting ignored. Try to find where each of the other entries on your final path are being set (/usr/local/sbin:/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin:/usr/local/bin:/root/bin) and put something like /bin/echo "before 1: path='$PATH'" /bin/echo "after 1: path='$PATH'" around each path assignment (changing the numbers, natch) to see where your changes are getting ignored. If if these messages don't come out on the console , add a redirect to a known file somewhere, and look at it after you have logged on. The underlying trick of all this is to treat system administration like a programming problem, and debug it using the tools you have available. Let us know if you find the problem.
Notice the 'pathmunge' function. What it does is either prepend or append a single path top the PATH variable, depending on whether or not the 'after' argument is present: To prepend /some/path to PATH
To append /some/path to PATH
This is similar to other entries in /etc/profile that use this function. Simply make sure to use pathmunge after it has been defined and before it becomes meaningless, that is before the line
And no, it does not make any sense to modify each user's ~/.profile separately. To provide a system-wide setting you should modify the system-wide /etc/profile instead. Commands in it will be executed upon each user's login.
Hi, Best Practices Question here. Im using SuSE7.3 with JDK 1.4. I installed the Linux bin file from java.sun.com (not the rpm) and added to the end of /etc/profile
My question is: Is it better to add these variables to profile, or on a user by user basis? Best Regards, Mark
Mark Fletcher wrote: Is it better to add these variables to profile, or on a user by user basis? The answer, as always, is "it depends". If you only ever have one version of Java on your system, and you want everybody to get the new version at the same time when you change it, then a single setting in /etc/profile is best. Beware, though, than each new release may break something (1.3 moved some stuff from com.sun to javax; 1.4 introduced the new "assert" keyword and can break JUnit tests, and has changed some of the JDBC classes etc.), so you need to make sure all users understand the impact of an upgrade. If you have more than one version of Java on your system, and different users need the ability to choose which one they use, then the only solution is local configuration for each user. beware though, that if you retire an old version, some users may syill be using it, and you will have to support all the versions on the system and advise all the users about configuring which Java to use. It's a tradeoff. What's your situation?
Mark Fletcher
Ranch Hand
Joined: Dec 08, 2001
Posts: 897
posted
0
Hi, Im the only one using the Linux box, at home. It connects to my Windows XP box and I do a lot of my development on the Windows XP box, then I transfer it over to the Linux box. Im using the Linux box mainly as an internal web server, with MySQL. J2EE/Tomcat/J2SE is also set up. Ive also just started playing about with Samba. The box is great for learning Linux on. However at some point Id like to apply the skills I learn at home in the workplace, and so picking up these "best practices" is very useful to me. Eventually Id like to migrate away from the Windows box and onto Linux completely, but there are still a few apps (read games) that I cant shake! I use KDE3 as my Windowmanager and Im impressed with how its come along. Cheers! Mark [ July 18, 2002: Message edited by: Mark Fletcher ]
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.