Why the JDK is automatically installed after I execute the .bin file?
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Why the JDK is installed automatically after I execute the .bin file?
I am a newbie, I am running a Red Hat Linux, I don't know how all this happened.
I have downloaded the JDK(jdk-6u5-linux-i586-rpm.bin) and executed it with "./", this action has generated several rpm files in the same folder as the .bin file, including "jdk-6u5-linux-i586.rpm", which I know from tutorials on the web should be executed with the "rpm" command to REALLY INSTALL the JDK, but the situation is different to me, when I tried to execute "rpm -ivh jdk-6u5-linux-i586.rpm", I was told the package was installed -- "package jdk-1.6.0_05-fcs is already installed", why this happened? and in which folder could I find the installed JDK?
Well, I have found that it is installed in /usr/java.
By the way, I forgot to ask another question. that is, after I execute "./jdk-6u5-linux-i586-rpm.bin", several files are generated, so what are these files?
As you discovered, the JDK actually consists of several different packages (each package in its own separate .rpm). The ".bin" file just lets you install everything you need at once. No fuss, no hassle. Just easier to use.
Make sense?
PS:
You might actually have *several* different Java's on your system - the one you installed - and other versions you might not even be aware of.
You might want to try:
Quote:
rpm -qa | grep -i java
from the command line to check.
You can also run
Quote:
rpm -ql sun-javadb-client-10.3.1-4.1.i386.rpm | less
to examine any particular package in detail.
You should also be able to do this from the GUI (but I confess, I don't know which GUI might be most convenient for your particular version of RedHat).
Apologies in advance that it's a bit confusing. Here's what's going on:
1. You downloaded and tried installing Java 6 from the Sun's Java web page. This is a Good Thing.
2. You executed the .bin to install Sun Java 6 on your Linux PC.
It apparently worked.
In an ideal world, you'd be done.
3. You noticed that the .bin appeared to contain several .rpm's.
This is true ... and it really shouldn't matter. The point is
that the ".bin" installed Java for you - all the components you
need, all at once. This, too, is a Good Thing.
4. Unfortunately, we don't know *where* the .bin installed your Sun Java yet.
Worse, we've discovered that there is also a different - incompatible - Java that came pre-installed on your system: Gnu Java.
5. Frankly, one thing you could do is to uninstall gjc (GNU Java). The one that's left should be your Sun Java, and everything should "just work".
Please consider this approach - it's not necessarily a bad idea.
6. But otherwise, read this article. It might answer some of your questions; it should suggest several good solutions:
Verify that your jdk is really in /usr/share/jdk1.6.0_03. Not all distros put their jdks in the same place; on top of that, you may have a higher version than 1.6.0_03. Adjust as required. You may also need to change the priority (50 in the script above). 50 should be fine but if you add more jdks, you should set a different value for each of them.
Then make the file executable with chmod +x and execute it as root.
We are half there.
Install galternatives (the alternative is to do everything from the command line but that would be rather more work). Galternatives should appear on your menu; if not, you can launch from the command line with
galternatives
Look over the many items that relate to the jdk and select the sun jdk version for each. The items should match the items that are listed in the script I posted above.
If you now run java -version, you system will return jdk1.6.0 instead of gcj.
You may still need to set JAVA_HOME in your /etc/profile or ./bash_profile:
export JAVA_HOME=/path/to/jdk
export J2RE_HOME=/path/to/jdk/jre
export CLASSPATH=.:JAVA_HOME:JAVA_HOME/lib
You need to log out for these to take effect or use the "source" command.
Test with echo $JAVA_HOME; it should return the path to your JAVA_HOME.
By following this procedure, you can install as many jdks as you like. You can then set the one you need by using galternatives (or the update-alternatives --config java set of commands). You would also need to edit your (/etc/)profile.
Please *don't* do that nonsense jay73 suggested unless you're *sure* the Java version you're installing happens to be the exact version in his post.
All that "update-alternatives" stuff should happen automatically during install (or update) ... but it's *extremely* error prone to deal with manually. I certainly wouldn't recommend it unless you know exactly what you're doing.
Please decide what approach you feel most comfortable with (who knows - maybe you *prefer* a million "update-alternatives" commands?), and please post back with any questions.
Verify that your jdk is really in /usr/share/jdk1.6.0_03
Quote:
on top of that, you may have a higher version than 1.6.0_03. Adjust as required
Wasn't that clear enough then? But OK, yes, the compat package does essentially the same thing. I tend to prefer the manual way because jpackage clashes with Fedora in more ways than one.
I read the article you suggested me reading, but actually I understood little, because there are so many commands I am not familiar with. so I think, before I become familiar with those commands, having the JDK working fine is enough to me for the moment.
After I set the environment variables, it works for command line complilation, and execution of Java program, and also for eclipse.
Thank you again!
LQ is a nice place for newbie like me.
I will bring questions with me when I come here next time.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.