我已经使用 eclipse 导出并将其导出为 jar 文件,但它在 eclipse 测试运行中工作正常,但不能作为 jar 文件工作,有人帮我吗?(我是java新手,这是我的第一个应用程序)
package com.java.folder;
import java.awt.*;
import java.awt.event.*;
import java.io.File;
import javax.swing.*;
public class javafolder extends JApplet implements ActionListener{
private String textLine = "";
JButton b1, b2;
TextField text1, text2;
Container content = getContentPane();
public void init() {
text1 = new TextField(8);
text2 = new TextField(8);
JLabel label = new JLabel("Folder Name");
label.setFont(new Font("Serif", Font.PLAIN, 12));
content.add(label);
add(text1);
content.setBackground(Color.white);
content.setLayout(new FlowLayout());
b1 = new JButton("Creat A Folder");
b1.addActionListener(this);
content.add(b1);
b2 = new JButton("Creat A Folder");
b2.addActionListener(this);
//content.add(b2);
}
// Called when the user clicks the button
public void actionPerformed(ActionEvent event) {
String s;
textLine = event.getActionCommand();
s = text1.getText();
String path = System.getProperty("user.dir");
File dir=new File(path+"/"+s);
if(dir.exists()){
JOptionPane.showMessageDialog(null, "Folder Name Already Exists!!! :(", "Error",
JOptionPane.ERROR_MESSAGE);
}else{
dir.mkdir();
JOptionPane.showMessageDialog(null, "Folder Created :) Folder path:"+dir, "INFORMATION_MESSAGE",
JOptionPane.INFORMATION_MESSAGE);
}
}
}