简体   繁体   English

将Java applet导出到.jar

[英]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! 当我双击导出的jar文件时,什么都没有出现,但是当我编译我的代码时,它运行良好!

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. 一个jar文件和一个applet是两个不同的东西。 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. 您无法通过双击jar文件来运行它,但必须从网页上调用它。

Consider reading this: 考虑阅读以下内容:

  1. Java Applet Java Applet

  2. JAR format JAR格式

  3. Java Web View (This might be interesting) Java Web视图 (这可能很有趣)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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