I am attempting to install Oracle's Java jdk and compile and run java programs on my Raspberry pi. Basically I am getting a Error: Could not find or load main class error when I try to run a java myfile.java.
The steps I took were:
tar -zxvf jdk-7u6-linux-arm-sfp.gz to unzip the jdkOn a side note, because the wheezy image was only 2GB, I partitioned the other 2GB of my 4GB SD card for some additional storage. That is where I unzipped my jdk and now when I want to run java or javac I have to use the full path. How can you modify the installation so that you can simply type in java with out the full path. Doesn't that have something to do with where the binaries are installed?
The JRE sounds like it's installed ok but you need to compile your java before you can run it. As the Pi is relatively slow, use your PC/Mac to compile your app:
javac myfile.java
Then you can copy myfile.class, which should contain a main method, to your Pi and run:
java your.package.name.myfile
You can test this on your PC/Mac (or Linux :) ) before copying to your Pi.
Your other issue is resolved by adding java to the PATH. Edit /etc/profile, and add:
PATH=${PATH}:/path/to/jdk/bin
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With