.jar 文件遇到困难
我正在尝试创建一个可执行的 .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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
应该创建正确的 -e 入口点。
Should create the right -e entry point.