gpt4 book ai didi

java - 示例代码的编译问题

转载 作者:行者123 更新时间:2023-11-30 03:45:16 26 4
gpt4 key购买 nike

文档中的示例,它可以编译,但我还没有设法让它运行。

>java -cp . SourceBee

Error: Could not find or load main class 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);
}
}

最佳答案

list 必须位于 META-INF 目录中

关于java - 示例代码的编译问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25921598/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com