Results 1 to 8 of 8
  1. #1
    desert1940fox is offline Member
    Join Date
    Jun 2008
    Posts
    2
    Rep Power
    0

    Default How do I export applets to jar

    Does anyone know how to export an applet to a jar file in eclipse?
    I tried doing it with export and I created a manifest file, but the jar still gives me a Fatal Exception when i try to open it.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    You may need to give us more information for us to be able to help figure out what isn't working right here. Eclipse has a Wizard that's pretty good at walking you through the process of creating the Jar. I suggest:

    1) Create the simplest of JApplet programs, check to make sure that it runs.
    2) Export this to a Jar file
    3) Report to us the complete text of any fatal exceptions encountered.

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

  4. #4
    desert1940fox is offline Member
    Join Date
    Jun 2008
    Posts
    2
    Rep Power
    0

    Default

    I am only able to play my game when i open an html page and do something like

    <applet code="GalacticWar.class"
    archive="galacticwar.jar"
    width= 1100 height =750>
    </applet>

    but when I click on the jar file, by itself, it just says Fatal Exception and it exits

    Can applets only be played in web browsers?

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Yes. either run it in a web browser or in the applet viewer, but they are not stand-alone programs (unless coded in a slightly tricky way).

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by Fubarable View Post
    but they are not stand-alone programs (unless coded in a slightly tricky way).
    I've seen that most people not worry about this ;) Because as you said, they want to embedded the application with the browser in most case. Actually in very lower level with the applet viewer.

  7. #7
    aqualicy is offline Member
    Join Date
    May 2010
    Posts
    2
    Rep Power
    0

    Default Help

    I Also have a problem making my things into a jar file as a JApplet, Think you guys could help me? (This is just the menu to my game... it is the same format basically)

    CODE BELOW


    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.*;

    import javax.swing.*;

    public class MenuTesting extends JApplet implements Runnable, KeyListener, MouseListener, MouseMotionListener
    {
    //I KNOW U NEED THIS BUT DONT KNOW WHAT TO DO
    public static void main(String[] args)
    {
    JFrame fr=new JFrame(); //Puttign the JApplet into a Frame
    fr.setBounds(0,0,1015,600);
    /*JApplet menu=new MenuTesting();
    fr.add(menu);*/ // DOESNT WORK

    fr.setVisible(true);
    }

    //Threads
    Thread main, thisThread;

    //Graphic Variables
    Dimension offDimension;
    Image offImage;
    Graphics offGraphics;
    Font f1;

    //KeyListener
    int code;
    String lastkey="M";

    //Animations
    MediaTracker tracker;

    //TESTING
    Image[] menu;
    int mouseX=0, mouseY=0;
    boolean edit=false;
    JFrame frame;

    public void init()
    {
    //Add-Ins
    addKeyListener(this);
    addMouseListener(this);
    addMouseMotionListener(this);
    tracker=new MediaTracker(this);

    f1 = new Font("SansSerif", Font.BOLD, 12);

    //TESTING
    menu = new Image[3];
    for (int i = 0 ; i <= 2 ; i++)
    {
    menu[i] = getImage(getCodeBase(), "Title" + i + ".gif");
    tracker.addImage(menu[i], 0);
    }

    frame=new JFrame("Identification");
    frame.addKeyListener(this);
    frame.addMouseListener(this);
    frame.addMouseMotionListener(this);
    frame.setBounds(300,300,500,200);





    //TESTING END

    //Set Screen/Variables
    resize(1015,600);
    }
    public void start()
    {
    main=new Thread(this);
    main.start();
    }
    public void stop(){}
    public void run()
    {
    thisThread=Thread.currentThread();
    while(main==thisThread)
    {
    if (edit==true)
    {
    frame.setVisible(true);
    if (frame.EXIT_ON_CLOSE==3)
    {
    edit=false;
    }
    }



    try{
    repaint();
    thisThread.sleep(0);
    }catch(InterruptedException e){}
    }
    }

    //Key Events
    public void keyTyped(KeyEvent t) {}
    public void keyPressed(KeyEvent p)
    {
    code = p.getKeyCode();
    lastkey = KeyEvent.getKeyText(code);
    }
    public void keyReleased(KeyEvent r)
    {
    code = r.getKeyCode();
    lastkey = KeyEvent.getKeyText(code);
    }

    //Mouse Events
    public void mouseClicked(MouseEvent e) {
    //System.out.println(mouseX+" and "+mouseY);
    }
    public void mouseEntered(MouseEvent e) {}
    public void mouseExited(MouseEvent e) {}
    public void mousePressed(MouseEvent e) {}
    public void mouseReleased(MouseEvent e)
    {
    if ((mouseX>100)&&(mouseX<400)&&(mouseY>420)&&(mouseY <570))
    {
    edit=true;
    }
    }
    public void mouseDragged(MouseEvent arg0) {}
    public void mouseMoved(MouseEvent e)
    {
    mouseX=e.getX();
    mouseY=e.getY();
    }


    //Graphics
    public void paint(Graphics g)
    {
    update(g);
    }
    public void update (Graphics g)
    {
    Dimension d = size();

    // Create the offscreen graphics context
    if ((offGraphics == null) || (d.width != offDimension.width)|| (d.height != offDimension.height))
    {
    offDimension = d;
    offImage = createImage(d.width, d.height);
    offGraphics = offImage.getGraphics();
    }

    // Erase the previous image
    offGraphics.setColor(getBackground());
    offGraphics.fillRect(0, 0, d.width, d.height);
    offGraphics.setColor(Color.black);

    //Draw Images
    if (tracker.statusID(0, true) == MediaTracker.COMPLETE)
    {
    drawMenu(offGraphics);
    }
    //Save Images offScreen
    g.drawImage(offImage, 0, 0, null);

    try{
    thisThread.sleep(0);
    }catch(InterruptedException e){}
    }

    public void drawMenu(Graphics g)
    {
    g.drawImage(menu[0],0,0,this);
    if (edit==false)
    {
    if ((mouseX>100)&&(mouseX<400)&&(mouseY>420)&&(mouseY <570))
    {
    g.drawImage(menu[2],0,385,this);
    }
    else
    {
    g.drawImage(menu[1],0,385,this);
    }
    }
    else
    {
    g.drawImage(menu[2],0,385,this);
    }
    }




    }

  8. #8
    Webuser is offline Senior Member
    Join Date
    Dec 2008
    Posts
    526
    Rep Power
    0

    Default

    Quote Originally Posted by desert1940fox View Post
    I am only able to play my game when i open an html page and do something like

    <applet code="GalacticWar.class"
    archive="galacticwar.jar"
    width= 1100 height =750>
    </applet>

    but when I click on the jar file, by itself, it just says Fatal Exception and it exits

    Can applets only be played in web browsers?
    Sure :) To make them run as a desktop you have to do some radical modifications. You have to modify its inner code and to put down MANIFEST main class info

Similar Threads

  1. Export data to xls
    By trill in forum Advanced Java
    Replies: 5
    Last Post: 03-24-2011, 06:13 AM
  2. Export csv in servlets
    By nida in forum Advanced Java
    Replies: 3
    Last Post: 05-25-2009, 08:03 PM
  3. Export to excel
    By nehaa in forum AWT / Swing
    Replies: 1
    Last Post: 04-30-2009, 03:44 PM
  4. export to excel
    By diana glz in forum Advanced Java
    Replies: 0
    Last Post: 03-14-2008, 12:01 AM
  5. export to excel
    By diana glz in forum New To Java
    Replies: 0
    Last Post: 03-13-2008, 10:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •