我已經使用eclipse導出並將其導出爲jar文件,但它在eclipse測試運行中工作正常,但不能作爲jar文件工作,任何人都可以幫助我嗎? (我是新的Java,這是我的第一個應用程序)如何導出爲可運行桌面應用程序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);
}
}
}
@ pino這應該是答案 – MadProgrammer 2013-04-29 10:23:25
我看到你從未批准任何問題的答案。你應該正式批准你認爲正確的答案。有關詳細信息,請參閱http://meta.stackexchange.com/a/65088。 – Pino 2013-04-30 07:16:21