.jar 文件遇到困难

发布于 2025-01-07 13:39:46 字数 1466 浏览 1 评论 0原文

我正在尝试创建一个可执行的 .jar 文件。我创建它,当我运行它时,它给我以下错误==>

无法加载主类清单属性 C:\Users\Anastasov\Desktop\test.jar

其中 C:\Users\Anastasov\Desktop\test.jar 是我的 .jar 文件的目录和名称 jar文件是test.jar。我正在关注这个教程 http://www.youtube.com/watch?v=hwVuK0X-0P0

以下是我所做的步骤:==> 所以我首先编译我的类,然后创建 myManifest.txt 并指定主类的位置,它位于 Jdialogs.java 中,最后我在 cmd 中编写:

jar cfm  test.jar myManifest.txt Jdialogs.class

然后创建 test.jar 并从顶部给我错误。如果有人熟悉它并且可以提供帮助,我们将不胜感激。
这是我的 Jdialogs.java 代码

   //Jdialogs.java
    //19.02.12

    import javax.swing.JOptionPane;
    class Jdialogs
    {
      public static void main(String[] args)
      {
       // JOptionPane.showMessageDialog(null, message, titile is a string, messageType can be error info warning...);
          int answer;
          do
          {
          answer = JOptionPane.showConfirmDialog(null, "Can you see this dialog ?");

        // do something with the asnwer
        JOptionPane.showMessageDialog(null, "The confirm returned=" + answer,
         "Confirm Value", JOptionPane.INFORMATION_MESSAGE );

        answer = JOptionPane.showConfirmDialog(null, "Rerun dmeo?", "Confirm Demo", JOptionPane.YES_NO_OPTION);
        System.out.println("Debug: Rerun Demo - Answer: " + answer);

          }while (answer == JOptionPane.YES_OPTION);

      }
    }

I am trying to create an executable .jar file. I create it and when I run it it is giving me the following error ==>

Failed to load Main-Class manifest atribute from
C:\Users\Anastasov\Desktop\test.jar

where C:\Users\Anastasov\Desktop\test.jar is the directory of my .jar file and the name of the
jar file is test.jar. I am following this tutorial by the way
http://www.youtube.com/watch?v=hwVuK0X-0P0

Here are the steps of what I have done: ==>
so I first compile my class than I create myManifest.txt and specify where the main class is and it is in the Jdialogs.java and finaly i write in cmd:

jar cfm  test.jar myManifest.txt Jdialogs.class

Then the test.jar is created and is giving me the error from the top. If anyone is familiar with it and can help It would be appreciated Cheers.
Here is my Jdialogs.java code

   //Jdialogs.java
    //19.02.12

    import javax.swing.JOptionPane;
    class Jdialogs
    {
      public static void main(String[] args)
      {
       // JOptionPane.showMessageDialog(null, message, titile is a string, messageType can be error info warning...);
          int answer;
          do
          {
          answer = JOptionPane.showConfirmDialog(null, "Can you see this dialog ?");

        // do something with the asnwer
        JOptionPane.showMessageDialog(null, "The confirm returned=" + answer,
         "Confirm Value", JOptionPane.INFORMATION_MESSAGE );

        answer = JOptionPane.showConfirmDialog(null, "Rerun dmeo?", "Confirm Demo", JOptionPane.YES_NO_OPTION);
        System.out.println("Debug: Rerun Demo - Answer: " + answer);

          }while (answer == JOptionPane.YES_OPTION);

      }
    }

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

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

发布评论

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

评论(1

森罗 2025-01-14 13:39:46
 jar cfe test.jar Jdialogs Jdialogs.class 

应该创建正确的 -e 入口点。

 jar cfe test.jar Jdialogs Jdialogs.class 

Should create the right -e entry point.

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