1

Firstly, I would like to apologize as I'm not quite sure whether this question is suitable to be on this site or Stackoverflow. I chose U&L eventually because the traffic here is much lower compared to SO, and it makes my question stay longer on the main page.

I'm currently on Elementary OS 0.3 Freya. After installing it, one of the first few things I did was getting the Java using the commands:

sudo add-apt-repository -y ppa:webupd8team/java

sudo apt-get update

sudo apt-get install oracle-java9-installer

However, at that point, I wasn't quite sure what kind of Java(JVM,JRE,JDK) I was actually installing due to unclear understanding regarding those terms. Everything was fine until I started to use Android Studio. The installation went smoothly but I was prompted an error on the start-up of the program itself. Having tried many ways but to no avail, I decided to reinstall my Java. This is the method I used to uninstall Java. To make sure that I've completely removed it, I run the command java --version to check. The result showed that I got the Java uninstalled but what exactly that sparked my curiosity was that I could still run my Android Studio, which is written in Java. And so I searched up and read this to clear up my misconception and realize that I had installed JRE twice because the JDK, which includes JRE, was also downloaded before the installation of Android Studio took place.

So, here's my question:

  1. When we execute the three lines I listed above to install Java, are we installing the JRE or the JDK?

  2. Do we need to install JRE if we are also going to install JDK? (Since JDK includes JRE)

  3. Is there any commands that can install JDK like those three lines?

  4. Why can't the system detect the JRE in the JDK I downloaded from the official site when I run java --version?

  5. What is the difference(s) between the program that is installed using terminal and those who is downloaded from the web?

Sorry for putting five questions in a single thread. And for reading my laughable experience. You probably are laughing at my stupidity now, but I still hope you can help out to clear my doubts. Thanks in advance.

  • I am only laughing at all those apologies. I recommend that you tidy the question a little. Then flag this comment as obsolete. – ctrl-alt-delor Jul 14 '15 at 21:05
  • Java 9??? Java 9 hasn't even been released yet. – saiarcot895 Jul 14 '15 at 23:00
  • @richard Hi! Thanks for the input Richard! Any advice on tidying up my questions? And, well, I believe the way I convey my message in the public (including internet) is already a habit now. Can't really put myself in superiority. :) – Caesium95 Jul 15 '15 at 2:56
  • @saiarcot895 Hi! Have a look at this youtube.com/watch?v=a94MxHHzn1Q #06 is the Java installation. – Caesium95 Jul 15 '15 at 3:01
  • I really like how they say "install Oracle Java" and ignore OpenJDK, and that too, to install Java 9, which is scheduled to be released in a year. – saiarcot895 Jul 15 '15 at 3:27
0

Try with OpenJDK 7+ first (available in the repository).

If it is not working, try

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer

to install the official, Java JDK. You should not need the first command as you already done it, but that's for future reference.

The run:

sudo update-alternatives --config java

in which you can specifically choose Java JDK. Then everything should work as expected.


PS: in my opinion, this question belongs here since it is OS specific and not related to programming per se. I mean, you could have replaced Java with any other program (well, that's the first time in a while that I've seen such a complicated installation on Linux, I guess this is Java's karma ;)

  • Hi! Thanks for the reply! Can you elaborate more on the first sentence? Don't really get it. Anyway, I already had the JDK downloaded in my OS, but not installed I guess. Will the commands given overwrite it or affect anything internally? Lastly, I can't mark this as answer as you didn't give me the answers for all questions (kind of my fault actually). I hope you understand. :) – Caesium95 Jul 15 '15 at 3:08
  • About the first sentence: openjdk is an alternative, open source, implementation of the Java language. It is in the repository, so you don't have to do anything special except an apt-get to install it and maybe the update alternatives to select it if you have multiple versions on your system. – user123418 Jul 15 '15 at 11:55
  • Abput your question. First it is a bad practice to ask for more than one in a post (actually, this is considered ok if these are side questions that should be trivially answered once the OP knows the main answer). Here, your problem is with Java for Android Studio. You should have a working one now. – user123418 Jul 15 '15 at 11:59
  • Downloading and installing from the original site was not meant to be for end users in Linux. That can happen, but not for things like Java. The problem is that these installers are a complete mess. – user123418 Jul 15 '15 at 12:01
  • For the difference between JRE and JDK, do you own homework, this is trivial and answered everywhere on the internet! For Buddah's sake! The answer is given as the very first link in google, you don't even have to go on the actual site! It is in google's link description. Please plug in your brain. (That said, I have no grudge against you, but please understand that the remaining questions have already be answered a thousand of tiles) – user123418 Jul 15 '15 at 12:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.