user1204570
user1204570

Reputation: 219

Hello World in JOGL

I'm new to both Java and Jogl, and recently ran across the following error:

ERROR for first line of code:

"The import net cannot be resolved" 

2ND LINE:

Multiple markers at this line
  - Syntax error, insert "}" to complete ClassBody
  - Syntax error, insert "}" to complete ClassBody

In other words the code's brackets and parenthesis are unbalanced.

import net.java.games.jogl.*;
public class HelloWorld {
  public static void main (String args[]) {
    try {
      System.loadLibrary("jogl");
      System.out.println(
        "Hello World! (The native libraries are installed.)"
      );

With the code now indented, it is apparent that I have a couple missing }'s. I have learned my lesson and will indent my code from now on.

Upvotes: 0

Views: 868

Answers (1)

Joe
Joe

Reputation: 15812

Classes don't have an access modified: public class HelloWorld should be class HelloWorld.

Your braces don't match up - you've opened some, but not closed them. It should look something like this:

public class HelloWorld
{ // open HelloWorld

    public static void main (String args[])
    { // open main
        try
        { // open try
            System.loadLibrary("jogl");
            System.out.println("Hello World! (The native libraries are installed.)");
        } // close try
        catch (Exception e) // all try's need a catch
        { } // even if the catch does nothing
    } // close main

} // close HelloWorld

As to the import not being resolved, pass. Someone else will drop by who knows more about this specific problem than I do :)

Upvotes: 1

Related Questions