JOGL 中的 Hello World

发布于 2025-01-04 21:41:40 字数 668 浏览 3 评论 0原文

我是 JavaJogl 的新手,最近遇到以下错误:

第一行代码错误:

"The import net cannot be resolved" 

第二行:

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

换句话说,代码的括号和圆括号不平衡。

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.)"
      );

现在代码已缩进,很明显我缺少几个 }。我已经吸取了教训,将从现在开始缩进我的代码。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心在旅行 2025-01-11 21:41:40

类没有修改访问权限:public class HelloWorld 应为 class HelloWorld

您的牙套不匹配 - 您打开了一些牙套,但没有闭合它们。它应该看起来像这样:

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

至于未解决的导入,请通过。其他人会比我更了解这个具体问题:)

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 :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文