源代码:
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);
}
}
清单文件行: Main-Class: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
答案 0 :(得分:2)
从你的主要文件中取出.class。只需使用类名,它就应该运行。
java -jar yourjar.jar