| 1 | | == Java on your OSWALD == |
|---|
| 2 | | This section describes how to use java on your OSWALD. The process is fairly simple, we will be working with a hello world program. There are a few steps, the first is to create the source, we will call it '''!HelloWorld.java''', make the file using a text editor and fill it in with the following contents. This step is done on your computer. |
|---|
| 3 | | {{{ |
|---|
| 4 | | #!java |
|---|
| 5 | | class HelloWorld { |
|---|
| 6 | | public static void main(String[] args) { |
|---|
| 7 | | System.out.println("Hello World!"); |
|---|
| 8 | | } |
|---|
| 9 | | } |
|---|
| 10 | | }}} |
|---|
| 11 | | The next step is to compile the java file into a class file, the easiest way is to make a project in eclipse (cs161 students should know how to do this), a guide for that can be found [https://eclipse-tutorial.dev.java.net/eclipse-tutorial/part1.html here] (Or you can make the class file using another method described [http://java.sun.com/docs/books/tutorial/getStarted/cupojava/index.html here]). Once you have made the project, run it once. Now navigate to the directory that your project is in, and find the '''!HelloWorld.class''' file, copy this to a flash drive, or SD card. Once you have put the card/drive into your OSWALD, open a terminal (click the little black icon on the bottom of the screen). Type one of the following commands: |
|---|
| 12 | | |
|---|
| 13 | | For sd cards: |
|---|
| 14 | | {{{ |
|---|
| 15 | | #!sh |
|---|
| 16 | | cd /media/mmcblk0p1 |
|---|
| 17 | | }}} |
|---|
| 18 | | For flash drives: |
|---|
| 19 | | {{{ |
|---|
| 20 | | #!sh |
|---|
| 21 | | cd /media/sda1 |
|---|
| 22 | | }}} |
|---|
| 23 | | Finally, we can run the java program using: |
|---|
| 24 | | {{{ |
|---|
| 25 | | #!sh |
|---|
| 26 | | java HelloWorld |
|---|
| 27 | | }}} |
|---|
| 28 | | If successful you should see: |
|---|
| 29 | | {{{ |
|---|
| 30 | | #!sh |
|---|
| 31 | | Hello World |
|---|
| 32 | | }}} |
|---|
| 33 | | On your terminal. |
|---|