来自文档的例子,它编译但我没有设法让它运行。
> java -cp。 SourceBee
错误:无法找到或加载主类SourceBee
我使用以下批处理文件:
@echo off
cd %1
echo Manifest-version: 1.0 > manifest.mf
echo Main-Class: %1 >> manifest.mf
javac %1.java
rem jar cvmf manifest.mf %1.jar %1.java
rem pause
rem java -jar %1.jar
java -cp . %1
cd ..
这是未经修改的来源:
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class SourceBee{
public static void main(String[] args) {
JFrame frame = new JFrame("SourceBee");
frame.setSize(800,600);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = new JPanel();
panel.setLayout(null);
JLabel userLabel = new JLabel("User");
userLabel.setBounds(10,10, 80, 25);
panel.add(userLabel);
JTextField userText = new JTextField(20);
userText.setBounds(100, 10, 160, 25);
panel.add(userText);
JButton loginButton = new JButton("login");
loginButton.setBounds(10, 80, 80, 25);
panel.add(loginButton);
JButton registerButton = new JButton("register");
registerButton.setBounds(180, 80, 80, 25);
panel.add(registerButton);
frame.add(panel);
frame.setVisible(true);
}
}
答案 0 :(得分:2)
清单必须位于META-INF目录
中