pi@raspberrypi ~/testProject $ sudo apt-get install openjdk-7-jreInstall the Java Development Kit
pi@raspberrypi ~/testProject $ sudo apt-get install openjdk-7-jdk
Check where Java is installed
pi@raspberrypi ~/testProject $ which javaIt was installed in /usr/bin/java on my Pi
Set up the JAVA_HOME environment variable
pi@raspberrypi ~/testProject $ export JAVA_HOME=/usrInstall ANT
pi@raspberrypi ~/testProject $ sudo apt-get install antMake a directory for the Java project
pi@raspberrypi ~/testProject $ mkdir ~/testProjectChange to the testProject directory
pi@raspberrypi ~/testProject $ cd ~/testProjectCreate a simple Java file Test.java. This just prints a message saying "Test.java is running".
public class Test { public static void main(String[] args) { System.out.println("Test.java is running"); } }
Create an ANT build file, build.xml
There is just one target in the build file to compile the source code. You can run the build file with ant by just running ant
pi@raspberrypi ~/testProject $ antAfter this finishes building, check the contents of the directory for the java class file
pi@raspberrypi ~/testProject $ lsRun the Java program
build.xml Test.class Test.java
pi@raspberrypi ~/testProject $ java Test
Test.java is running
No comments:
Post a Comment