Changes between Version 5 and Version 6 of CSPFL_Java

Show
Ignore:
Author:
hardert (IP: 67.169.210.177)
Timestamp:
11/03/09 19:14:06 (3 weeks ago)
Comment:

Move gcj docs into the Java page

Legend:

Unmodified
Added
Removed
Modified
  • CSPFL_Java

    v5 v6  
    2929{{{ 
    3030#!sh 
    31 Hello World 
     31Hello World! 
    3232}}} 
    3333On your terminal. 
     34 
     35= Compiling java code using gcj = 
     36 
     37Java source code (.java files) can be compiled using the command 'gcj'. 
     38 
     39For example: 
     40{{{ 
     41#!sh 
     42gcj HelloWorld.java 
     43}}} 
     44 
     45This example will not work, however, as gcj must be told which main method to run when specifying source files, for example: 
     46 
     47{{{ 
     48#!sh 
     49gcj --main=HelloWorld -o HelloWorld HelloWorld.java 
     50}}} 
     51 
     52The parameter "--main=<className>" tells the compiler that the executable should run the main within the !HelloWorld class and the "-o" parameter specifies the output file. 
     53 
     54If the code is successfully compiled, the executable will be a file named "!HelloWorld in the current working directory. If no output file is specified, the executable will be the file named "a.out" in the current working directory. 
     55 
     56Run the program from the current working directory with the following command: 
     57 
     58{{{ 
     59#!sh 
     60./HelloWorld 
     61}}} 
     62 
     63To compile to java bytecode (.class file), use the -C option: 
     64 
     65{{{ 
     66#!sh 
     67gcj -C HelloWorld.java 
     68}}} 
     69 
     70This command will produce "!HelloWorld.class" which can then be run in the java virtual machine: 
     71 
     72{{{ 
     73#!sh 
     74java HelloWorld 
     75}}} 
     76 
     77Notice that you only specify the class name, not the bytecode file name. 
    3478 
    3579== Using the Joystick ==