0
我創建具有GUI .jar文件:創建一個.jar文件
jar cmf mainClass patcherFull.jar pack
我得到與上面的創建命令沒有錯誤,但隨後運行.jar文件不執行任何操作在Windows中,與Java本身輸出運行它:
java -jar patcherFull.jar
java.lang.NoClassDefFoundError: patcherFull
Caused by: java.lang.ClassNotFoundException: patcherFull
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: patcherFull. Program will exit.
Exception in thread "main"
這是我的代碼結構:
public class patcherFull extends JPanel implements ActionListener, PropertyChangeListener
{
private JProgressBar progressBar;
private JButton startButton, closeButton;
private JLabel status;
private Task task;
class Task extends SwingWorker<Void, Void> {
@Override
public Void doInBackground()
{
}
@Override
public void done()
{
}
}
public patcherFull()
{
}
public void actionPerformed(ActionEvent evt)
{
}
public void propertyChange(PropertyChangeEvent evt)
{
}
private static void createAndShowGUI()
{
}
public static void main(String[] args)
{
javax.swing.SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
createAndShowGUI();
}
});
}
}
這是我mainClass清單FIL e(在最後有一個新行):
Main-Class: patcherFull
我的代碼結構中有什麼問題嗎?作爲參考,「pack」文件夾包含3個生成的.class文件,2個依賴項(一個jpg和一個exe),然後是「patcherFull.java」文件。
這裏是關於的.jar裏面是什麼的一些信息:
$ jar tf patcherFull.jar
META-INF/
META-INF/MANIFEST.MF
pack/
pack/banner.jpg
pack/patcherFull$1.class
pack/patcherFull$Task.class
pack/patcherFull.class
pack/patcherFull.java
pack/wget.exe
所以你的意思是改變我的清單文件爲「Main-Class:pack.patcherFull」?我這樣做的時候會出錯。當您創建罐子時, – carget 2011-12-22 23:22:18
站在'pack'內 – 2011-12-22 23:46:27