简体   繁体   中英

Export Java applet to .jar

My problem is :

When I tried to export my applet, I couldn't find the 'main class'. When I double click on the exported jar file, nothing appears, but when I compile my code it works fine!

The code here         

import java.applet.*;
import java.net.*;
import javax.swing.*;
import javax.swing.border.Border;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.net.URL;

public class Jap_Learn extends JApplet {
    AudioClip SOUND;
    AudioClip SOUND1;
    public void init() {


    Dimension Screensize =
        Toolkit.getDefaultToolkit().getScreenSize();
    JFrame fr = new MainFrame();
    String Serial;
    Serial = JOptionPane.showInputDialog("Set serial of The prOduct");
    int ISerial;
    ISerial = Integer.parseInt(Serial);
    if(ISerial == 47)
    {fr.show();
    SOUND = getAudioClip(getCodeBase(),"Music.wav");

    SOUND.play();}
    else
    {
    SOUND1 = getAudioClip(getCodeBase(),"TestSnd.wav");
    SOUND1.play();
    JOptionPane.showMessageDialog(null, "wrOng serial !");     
    }


}

A jar file and an applet are two different things. You should consider reading some basics about them. A applet is launched form a web page and has no main method. It has its own cycle of methods. You cant run it by double clicking the jar file but you have to call it from a web page.

Consider reading this:

  1. Java Applet

  2. JAR format

  3. Java Web View (This might be interesting)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM