Хотя этот вопрос, возможно, уже задавался много раз в SO, я не могу создать исполняемый файл Java (* .jar).
Я пытался внимательно следовать инструкциям решения с наибольшим количеством голосов на Как создать исполняемую Java-программу? , но когда я дважды щелкнул файл jar, ничего не произошло (всплывающее окно отсутствует) окно появилось). Посоветуйте, пожалуйста, что тут может быть не так.
Спасибо.
============ UPDATE ===================
Для тех, кто хочет знать, вот исходный код, который я использовал:
HelloWorldSwing.java
package start;
import javax.swing.*;
public class HelloWorldSwing {
public static void main(String[] args) {
//Create and set up the window.
JFrame frame = new JFrame("HelloWorldSwing");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JLabel label = new JLabel("Hello World");
frame.add(label);
//Display the window.
frame.pack();
frame.setVisible(true);
}
}
class Dummy {
// just to have another thing to pack in the jar
}
Manifest.mf
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.4
Created-By: 1.8.0_172 (Oracle Corporation)
Main-Class: HelloWorldSwing
=========================================
Теперь, я попробовал это с другим * .java файлом, и та же проблема повторяется! Пожалуйста, смотрите код ниже для деталей:
Код:
SwingExample.java
import java.awt.FlowLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;
public class SwingExample implements Runnable {
@Override
public void run() {
// Create the window
JFrame f = new JFrame("Hello, !");
// Sets the behavior for when the window is closed
f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
// Add a layout manager so that the button is not placed on top of the label
f.setLayout(new FlowLayout());
// Add a label and a button
f.add(new JLabel("Hello, world!"));
f.add(new JButton("Press me!"));
// Arrange the components inside the window
f.pack();
// By default, the window is not visible. Make it visible.
f.setVisible(true);
}
public static void main(String[] args) {
SwingExample se = new SwingExample();
// Schedules the application to be run at the correct time in the event queue.
SwingUtilities.invokeLater(se);
}
}
Manifest.mf
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.4
Created-By: 1.8.0_172 (Oracle Corporation)
Main-class: start.SwingExample
WTH здесь происходит ???