Tell me more ×
Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It's 100% free, no registration required.

I am an experienced Java programmer who received the raspberry pi for Christmas. Unfortunately, it appears that only Python is installed in it. What command do I type at the start command line where I would usually type startx to install the JDK and Jre

share|improve this question

3 Answers

up vote 2 down vote accepted
+50

The oracle 8 preview works for me, thus far. Compiling is slow on the pi, surprise, but the jre seems to run quite fast once it loads. I think bearbin's answer is pretty definitive but if you want a simple way to try oracle:

  1. Download. You get a .tar.gz file, which is a gzipped tarball.
  2. Put the .tar.gz in /usr/local and unpack it: tar -xzf oracle8-blah-blah.tar.gz. This will create a directory with everything in it. You can rename the directory, mv oracle-jdk-whatever jdk1.8.0. Everything in there is self-contained.
  3. Put the bin/ directory at the beginning of your executable search $PATH. If there are any other javas installed, that will make this one take precedence: PATH=/usr/local/jdk1.8.0/bin:$PATH.

That will only work for your current shell. To make it the default from now on, add this to ~/.profile:

export PATH=/usr/local/jdk1.8.0/bin:$PATH
share|improve this answer
Thank you all! Finally i dont have to use python >.< – imulsion Feb 11 at 17:43

To install the Java Runtime Environment (JRE) run the following command:

sudo apt-get install openjdk-7-jre

This installs the Java JRE (Java Runtime Environment) which will allow you to run applications written in Java.

To install the JDK run the command:

sudo apt-get install openjdk-7-jdk

This allows you to compile Java applications to bytecode.

If you want the Oracle Java VM, which is a lot faster (optimized for embedded arm CPUs) and is also a developer preview (applications maybe buggy or crash) until some time into the future. Instead of the above instructions you need to download the file called Oracle JDK 8 (with JavaFX) for ARM Early Access on the Oracle Java 8 download page.

Remember to download the Oracle Java system on your Pi, or you won't be able to install it.

To install the Oracle Java System:

tar zxvf jdk-8-ea-b36e-linux-arm-hflt-*.tar.gz -C /opt
sudo update-alternatives --install "/usr/bin/java" "java" "/opt/jdk1.8.0/bin/java" 1 
sudo update-alternatives for other commands if needed.
java -version

Then it is all installed.

Another thing, if you have more then one Java runtime installed you have to check which version you use with the commando java -version. If the output is:

java version 1.5.0 gij (GNU libgij)

Then you are using a other java runtime. You can resolve the issue by running

sudo update-alternatives --config java

and choosing the OpenJDK or Oracle option.

share|improve this answer
when running tar zxvf jdk... command, two errors (second is repeated): tar (child): jdk...tar.gz: no such file or directory tar (child): fatal error received. exiting now – imulsion Feb 6 at 18:06
@imulsion The file may have a slightly different name - type the ls command and use the file with a similar name instead. – bearbin Feb 6 at 18:15
what to type after ls? – imulsion Feb 6 at 18:30
tar zxvf [] where [] is the file with a similar name. – bearbin Feb 6 at 18:47

sudo apt-get install java-runtime

This is OpenJDK 6.

Oracle JDK is not available in armhf flavor, so you have to use a soft-float image to use it.

share|improve this answer
3  
Oracle JDK 8 is available in a developer preview. For my case it is working without any problem. raspberrypi.org/phpBB3/viewtopic.php?f=81&t=26110 – otakun85 Jan 26 at 18:36
@M Noit it says there are loads of packages that i can install and i need to specify one. what to type in? – imulsion Feb 5 at 17:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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