Export Java applet to .jar
Asked Answered
L

1

2

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 !");     
    }


}
Livestock answered 26/7, 2013 at 16:35 Comment(2)
Why code an applet? If it is due due to spec. by teacher, please refer them to Why CS teachers should stop teaching Java applets.Auria
before,i didn't code an applet , but that causes me a problem the Method getCodeBase() getting error ! so when i changed main() to init(), it's worked but the option of creating a jar file which excute by double click gOne :'(Livestock
A
1

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)

Acanthocephalan answered 26/7, 2013 at 16:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.