我已经好几年没有编写任何程序了,但我编写这个小程序是为了帮助解决我们在工作中遇到的问题。我做了一些关于如何制作 jar 文件的作业并遵循了这些步骤。当我尝试执行创建的 jar 文件时,没有任何反应。有人能指出我正确的方向吗?
源代码:
import java.io.*;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
public class CardOutput
{
public static void main(String[] args) throws IOException
{
String inputA;
JFrame parent = new JFrame();
boolean truth = true;
while(truth)
{
inputA = JOptionPane.showInputDialog("Please Swipe Card");
if(inputA.length() == 0)
{
truth = false;
}
else if(inputA.length() != 14)
{
inputA = JOptionPane.showInputDialog("Invalid Card Number \n" + "Please Swipe Card");
}
else
{
JOptionPane.showMessageDialog(parent, "Your Card Number is " + inputA.substring(4,13));
}
}
JOptionPane.showMessageDialog(parent, "Program is now ending");
System.exit(0);
}
}
list 文件行:主类:CardOutput.class
我创建的用于形成 .jar 文件的批处理文件:
@ECHO OFF
C:
CD "C:\Users\timmcj\Desktop\CardOutput
"C:\Program Files\Java\JDK1.7.0_09\bin\jar.exe" cvfm CardOutput.jar manifest.txt *.class
PAUSE
最佳答案
将 .class 从 mainifest 中取出。只需使用类名,它就应该运行。
java -jar yourjar.jar
关于java - jar文件不会执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13104558/