1

I have downloaded the latest OS for the pi from here http://downloads.raspberrypi.org/raspbian_latest

Then i have downloaded the latest Java JDK to run my JavaFX application from http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html and selected the Hard Flat v6/v7 file.

I have transferred and unzipped the JavaJDK onto my Pi.

Now if i execute this command on my local machine, my application starts

Java -jar program_name.jar

But if i run the same command on the Pi, i get an error saying

Could not find or load main class application.Main

If i change the .jar file into a .zip, i can clearly see a directory called application, and file called Main.class

So why is my program working on my (windows 10) machine, whether i run it from eclipse or the command line, but not on the raspberry Pi?

Gillardo
  • 9,518
  • 18
  • 73
  • 141
  • 4
    Check this [question](http://stackoverflow.com/questions/28284239/javafx-ensemble-on-raspberry-pi) – José Pereda Sep 20 '15 at 10:55
  • Is javafx not recommended anymore then? Should we use something else to develop for arm now? – Gillardo Sep 20 '15 at 13:58
  • 1
    It is not the case that JavaFX is *not recommended*. JavaFX is not bundled with JDK 8 for arm, but it can be added downloading an updated version for arm from [here](http://gluonhq.com/open-source/javafxports/downloads/). So if you want to develop for arm with Java, you can still use JavaFX. – José Pereda Sep 20 '15 at 14:08

1 Answers1

1

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:

sudo 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 (e.g. javac). 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 command java -version. If the output is:

java version 1.5.0 gij (GNU libgij) Then you are using another java runtime. You can resolve the issue by running

sudo update-alternatives --config java

and choosing the OpenJDK or Oracle option.

Omid Goudazi
  • 120
  • 2
  • 9