LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Java and RedHat 9.0 or "Why Bill Gates Never Has To Worry" (https://www.linuxquestions.org/questions/linux-general-1/java-and-redhat-9-0-or-why-bill-gates-never-has-to-worry-82962/)

p.z 08-17-2003 10:20 PM

Java and RedHat 9.0 or "Why Bill Gates Never Has To Worry"
 
Warning: :newbie:

<soapbox>
Argh. This is the same problem I've had every time I think I'm going to use Linux.....I get so far and then whamo....all development stops because support documentation just does not exist.....

First off, I am trying to install Java on RedHat 9.0. I don't enjoy spending the weekend pouring over every conceivable support forum and documentation piece to install something as rudimentary as Java. ...but...welcome to the freedom of linux ;)

I think I'm pretty patient and like to learn new things especially when it comes to technology but this is outrageous and exactly the reason I will continue to tell users to avoid Linux. (blah blah blah its not the software its the user but goddamn if any users with less computing experience could do this either)
</soapbox>

Off the soapbox and onto the problem....

<problem>
I first formatted my drive to "Start fresh". I updated all packages to have the freshest possible OS without corruption.

I then downloaded the latest version of java which is supposedly: j2re-1_4_2-linux-i586-rpm.bin found at
java.sun.com/j2se/downloads.htm

Off the bat I'm confused. all the resource material says "j2sdk-1_4_2_<version>-linux-i586.bin" so I cant really understand why Sun.com is giving me j2sdk instead of j2re in all the resource/installation instructions....

I followed the install instructions completely...
java.sun.com/j2se/1.4.2/install-linux.html

i thought i screwed something up but it did install because i get an ALREADY INSTALLED MESSAGE when I tried a reinstall......HOWEVER

when i type:
java -version

i get:
bash: java: command not found

I have not added anything to my PATH yet because (surprise) I cant even find WHERE the Path is.

a file search for "java" gives me this file found in usr/share/:

libgcj-<version>.jar

</problem>

p.z 08-17-2003 10:36 PM

i cannnot believe RedHat 9 is incompatible with Sun Java.

Is Mandrake better?

p.z 08-17-2003 10:38 PM

developer.java.sun.com/developer/technicalArticles/JavaTechandLinux/RedHat/

Red Hat Linux 9 and Java 2 Platform, Standard Edition 1.4.2: A Winning Combination
By Janice J. Heiss
August 2003

I DONT F*CKING GET IT WHY WRITE THIS ARTICLE IF THE OS DOESNT SUPPORT IT?!?

p.z 08-17-2003 10:44 PM

omg i found the actual java files installed on my system....

p.z 08-17-2003 10:52 PM

"No Java virtual machine Could be found from your PATH environment variable"

* sigh *

MiscGeek 08-17-2003 10:54 PM

Dude... chill :) It usually installs in the /usr/java directory..., although it sounds like you've found it alread :)

Here's something that might help you in the future when you install an rpm and can't find where it put stuff.

Run "rpm -q --filesbypkg <package-name>". It will give you list of all files installed for the package.

Mike

p.z 08-17-2003 10:57 PM

Quote:

Originally posted by MiscGeek
Dude... chill :) It usually installs in the /usr/java directory..., although it sounds like you've found it alread :)

Here's something that might help you in the future when you install an rpm and can't find where it put stuff.

Run "rpm -q --filesbypkg <package-name>". It will give you list of all files installed for the package.

Mike

Thanks Mike, I found the files but the location is useless since I can't seem to add it to the path correctly. I tried adding it to the Path and Java is still not working

MiscGeek 08-17-2003 10:58 PM

Quote:

Originally posted by p.z
"No Java virtual machine Could be found from your PATH environment variable"

* sigh *

Hmmm.. that's a new one on me :( Have you modified your $PATH in either the /etc/profile or ~/.bashrc and added path-to-java/bin/java to it?

Mike

p.z 08-17-2003 10:59 PM

Quote:

Originally posted by MiscGeek
Hmmm.. that's a new one on me :( Have you modified your $PATH in either the /etc/profile or ~/.bashrc and added path-to-java/bin/java to it?

Mike

This is the part I am unsure of. How do i add to the path? Do I manually edit the files in a text editor or through command line? None of the SUN resource material guides you through this part.

Which one do I add to? Both? Do I need to be root?

Argh! There are files in those directories you mentioned /etc/profile.d/ but How do i edit these...as root? With a text editor.


MiscGeek 08-17-2003 11:10 PM

Quote:

Originally posted by p.z
This is the part I am unsure of. How do i add to the path? Do I manually edit the files in a text editor or through command line? None of the SUN resource material guides you through this part.
You can change your path at the command line but for it to be permanent you will need to edit the text files. If you want the change to affect all users you would modify /etc/profile. If this is your development box and/or you are the only one that needs java you can just edit your /<user_name>/.bashrc file, replace <user_name> with your login name.

You can edit it with your favorite editor.

Here's the lines from my .bashrc. You will have to adjust them to match your setup. All of them are not really necessary but won't hurt :)

export JAVA_HOME="/usr/java/j2sdk1.4.2"
export JDK_HOME="$JAVA_HOME"
export JAVA_PATH="$JAVA_HOME"
export PATH="$PATH:$JAVA_HOME/bin"

The same lines could be added to the /etc/profile file but you will need to be root to modify it :)

Note: You may need to logout and back in for the changes to take effect.

Mike

p.z 08-17-2003 11:13 PM

Quote:

Originally posted by MiscGeek
You can change your path at the command line but for it to be permanent you will need to edit the text files. If you want the change to affect all users you would modify /etc/profile. If this is your development box and/or you are the only one that needs java you can just edit your /<user_name>/.bashrc file, replace <user_name> with your login name.

You can edit it with your favorite editor.

Mike

When I search for "bashrc" i only get two files...

in /etc
in /usr/share/doc/bash<version>/startupfiles/

Im assuming it is one of these files but it is not in the location you said.

How do i search for .bashrc files? Can they be found by the redhat file search feature?

wdingus 08-17-2003 11:18 PM

Bear in mind that I admin a lot of RH9 servers but don't use Java myself and have never tried to install it. Thought I'd take a stab at it just for the heck of it though...

http://java.sun.com/j2se/1.4.2/download.html seems to be the place to be, small amount of surfing their site to find the download page. Downloaded the Linux JRE rpm "bin" file. Odd, it's not an RPM, it's a binary file you run that extracts an RPM file. Makes you agree to the license agreement so that's why they do that. No big deal...

# chmod a+rx j2re-1_4_2-linux-i586-rpm.bin
# ./j2re-1_4_2-linux-i586-rpm.bin
# rpm -ivh j2re-1_4_2-linux-i586.rpm
# java -version

At this point it still shows the installed RH9 Java stuff, whatever it is... So

# rpm -ql j2re-1.4.2-fcs

Shows me all the stuff from that Sun JRE RPM went into /usr/java/j2re1.4.2 In there is a bin directory with a java executable in it.

# /usr/java/j2re1.4.2/bin/java -version

That looks like it... OK, so this /usr/java/j2re1.4.2/bin directory is new and is NOT in my path... I'm logged in as root so:

# vi /root/.bash_profile

This line:
PATH=$PATH:$HOME/bin
I changed to:
PATH=$HOME/bin:/usr/java/j2re1.4.2/bin/:$PATH

Previously it took the contents of the environment variable $PATH and set it equal to itself and $HOME/bin appended to it. I changed it to make the PATH $HOME/bin, then the java bin directory, and then the rest of whatever itself was already set to. Logged out and back in and java -version now gives what I expect.

Potential problems with this way of modifying the path is that running things from cron or 'at' jobs or automated scripts might still use the default path and not find the Sun 1.4.2 Java files. Probably /etc/profile would need to be appropriately modified to set the correct PATH or make sure to give the full path in any scripts or cron jobs or whatever to the executable you want. Many other ways to skin this cat, that's just a couple.

Good luck!

MiscGeek 08-17-2003 11:21 PM

Quote:

Originally posted by p.z
When I search for "bashrc" i only get two files...

in /etc
in /usr/share/doc/bash<version>/startupfiles/

Im assuming it is one of these files but it is not in the location you said.

How do i search for .bashrc files? Can they be found by the redhat file search feature?

Looks like you forgot the "." before the name :) There is one in the /etc directory but it's just the default.

Find files should find it make sure you include the "." i.e. ( .bashrc ), and that it is searching in "/home/<your_login_name/". Sorry, I think I may have left /home/ out in my previous post :(

Mike

p.z 08-17-2003 11:23 PM

File is named: .bashrc

No Files Found

* sigh *

starting to cry

p.z 08-17-2003 11:26 PM

Wait...i found the file....but the Redhat Search feature doesnt find .hidden files...

okay...going slow...being patient.

MiscGeek 08-17-2003 11:27 PM

Quote:

Originally posted by wdingus

Potential problems with this way of modifying the path is that running things from cron or 'at' jobs or automated scripts might still use the default path and not find the Sun 1.4.2 Java files. Probably /etc/profile would need to be appropriately modified to set the correct PATH or make sure to give the full path in any scripts or cron jobs or whatever to the executable you want. Many other ways to skin this cat, that's just a couple.

Good luck!

wdingus,

Yeah, I have several java apps that run under cron and it doesn't look like cron uses the /etc/profile by default. I end up having to source it in the scripts that start the java programs, " . /etc/profile ". :)

Mike

p.z 08-17-2003 11:32 PM

You people are great. Still trying to get it going...but all the help gives me confidence in the OS.

p.z 08-17-2003 11:34 PM

Okay...

java -version now GIVES ME RESULTS.

Thank god, and thank you good people.

MiscGeek 08-17-2003 11:38 PM

That's what we're here for. All of us have been there before and at least for me, had to look for help :) Just wish I had found LQ when I first started using Linux :)

MiscGeek 08-17-2003 11:40 PM

Quote:

Originally posted by p.z
Okay...

java -version now GIVES ME RESULTS.

Thank god, and thank you good people.

Awesome, and you are quite welcome :)


All times are GMT -5. The time now is 11:06 AM.