How can I compile the x10 example?

649 Views Asked by At

I'm currently reading this and I try to compile the very first example

// file HelloWorld.x10
public class HelloWorld {
    public static def main(args: Array[String](1)){
        x10.io.Console.OUT.println("Hello, World");
    }
}

I have Linux Mint 16. I set export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/. I've downloaded the "Linux/x86_64 (tgz)" version from http://x10-lang.org/x10-development/building-x10-from-source.html?id=248

I've tried to compile it like this:

$ ./x10 HelloWorld.x10       
Error: Cannot load main class for HelloWorld.x10 with classpath .:/home/moose/Downloads/x10-2.4.2_linux_x86_64/stdlib/x10.jar:/home/moose/Downloads/x10-2.4.2_linux_x86_64/lib/commons-math3-3.2.jar:/home/moose/Downloads/x10-2.4.2_linux_x86_64/lib/commons-logging-1.1.3.jar

and this:

./x10c HelloWorld.x10
/home/moose/Downloads/x10-2.4.2_linux_x86_64/bin/HelloWorld.x10:3: Could not find type "Array(x10.lang.Long)".
1 error.

and this

./x10c++ HelloWorld.x10
/home/moose/Downloads/x10-2.4.2_linux_x86_64/bin/HelloWorld.x10:3: Could not find type "Array(x10.lang.Long)".
1 error.

and this:

./runx10 HelloWorld.x10
/home/moose/Downloads/x10-2.4.2_linux_x86_64/bin/HelloWorld.x10: line 1: //: Is a directory
/home/moose/Downloads/x10-2.4.2_linux_x86_64/bin/HelloWorld.x10: line 2: public: command not found
/home/moose/Downloads/x10-2.4.2_linux_x86_64/bin/HelloWorld.x10: line 3: syntax error near unexpected token `('
/home/moose/Downloads/x10-2.4.2_linux_x86_64/bin/HelloWorld.x10: line 3: `    public static def main(args: Array[String](1)){'

How should I run / execute it?

1

There are 1 best solutions below

3
Josh Milthorpe On BEST ANSWER

The signature of the main method has changed between version 2.1 (on which the introduction you're reading was based) and version 2.4. The correct signature is:

public static def main(args:Rail[String])

A current version of "Hello World" (along with other examples) is included in the X10 distribution in x10.dist/samples . A more up-to-date introduction to X10 is available at http://x10.sourceforge.net/documentation/intro/latest/html/