Skip to content

Undesired sample code run result in the "Executing as a Shebang File" section of the "Launching Simple Source-Code Programs" tutorial #205

@brlin-tw

Description

@brlin-tw

In the "Executing as a Shebang File" section of the "Launching Simple Source-Code Programs" tutorial the following sample code is presented:

#!/path/to/your/bin/java --source 25
 
public class HelloJava {
 
    public static void main(String[] args) {
        IO.println("Hello " + args[0]);
    }
}

with the following run instructions

./HelloJava

As the sample code expects an command argument to be provided, it will result in the following runtime error:

$ ./HelloJava 
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
        at HelloJava.main(HelloJava:6)

I suggest:

  • Replacing the sample code with a simple "Hello world" one
  • Fixing the program run instructions to have a command argument available.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions