Results 1 to 7 of 7
  1. #1
    Zahari is offline Member
    Join Date
    Dec 2007
    Posts
    5
    Rep Power
    0

    Default call executable jar from html/jsp

    hello friends,
    i have a problem to call executable jar using html/jsp.

    i use the same code in applet. but be nothing.
    help me.

    if can send to my email, putraikim_n9@yahoo.com

    thanks.

  2. #2
    wsaryada is offline Senior Member
    Join Date
    Jun 2007
    Location
    Bali, Indonesia
    Posts
    757
    Rep Power
    7

    Default

    Can you post your code so we know what you really want to do in your JSP page.

  3. #3
    Zahari is offline Member
    Join Date
    Dec 2007
    Posts
    5
    Rep Power
    0

    Default call executable jar from html/jsp

    i have executable jar file example calculator.jar
    i want to run it by called using jsp/html
    i'm not using applet in my source code.

    i try to use this code, but error occur "loaded applet failed"

    <applet code=calculator.class
    archive="calculator.jar"
    width=640 height=480>
    </applet>

    actually in jsp/html, when the page has loaded, the executable jar must be run first.
    Last edited by Zahari; 12-05-2007 at 12:05 AM.

  4. #4
    wsaryada is offline Senior Member
    Join Date
    Jun 2007
    Location
    Bali, Indonesia
    Posts
    757
    Rep Power
    7

    Default

    So your calculator class is not a Java applet? That means you cannot use the applet tag to run your calculator class. Can you post your calculator class definition?

  5. #5
    Zahari is offline Member
    Join Date
    Dec 2007
    Posts
    5
    Rep Power
    0

    Default

    class calculator
    {
    public static void main(String[]args)
    {
    new calculator();
    }

    public calculator()
    {
    //GUI code
    }
    }

    then i convert into executable jar.(calculator.jar)
    when manually doubleclick it run but
    i want to call it from html/jsp.
    thanks.

  6. #6
    wsaryada is offline Senior Member
    Join Date
    Jun 2007
    Location
    Bali, Indonesia
    Posts
    757
    Rep Power
    7

    Default

    Well, I believe i cannot be done this way. You need to create an applet that you embed on your page or you can create a swing application and then use java webstart to distribute your application.

  7. #7
    Zahari is offline Member
    Join Date
    Dec 2007
    Posts
    5
    Rep Power
    0

    Default

    what is java webstart? i use java swing application to write the program.
    if i used java applet how can i convert it to executable jar file?

    myCalculator.java

    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;

    public class myCalculator extends JFrame implements ActionListener
    {
    JLabel jlbNo1 = new JLabel("Nombor Pertama : ");
    JLabel jlbNo2 = new JLabel("Nombor Kedua : ");
    JLabel jlbResult = new JLabel("Keputusan : ");

    JTextField jtfNo1 = new JTextField(20);
    JTextField jtfNo2= new JTextField(20);
    JTextField jtfResult = new JTextField(20);

    JButton jbtTambah = new JButton();
    JButton jbtTolak = new JButton();
    JButton jbtDarab = new JButton();
    JButton jbtBahagi = new JButton();

    JMenu jmnFail = new JMenu("Fail");
    JMenu jmnOps = new JMenu("Operasi");

    JMenuItem jmiKeluar = new JMenuItem("Keluar");
    JMenuItem jmiTambah = new JMenuItem("Tambah");
    JMenuItem jmiTolak = new JMenuItem("Tolak");
    JMenuItem jmiDarab = new JMenuItem("Darab");
    JMenuItem jmiBahagi = new JMenuItem("Bahagi");


    myCalculator()
    {
    Container bekas = getContentPane();
    bekas.setLayout(new BorderLayout(5,10));
    bekas.setBackground(Color.blue);

    JMenuBar jmb = new JMenuBar();
    setJMenuBar(jmb);

    jmb.add(jmnFail);
    jmb.add(jmnOps);

    jmnFail.add(jmiKeluar);
    jmnOps.add(jmiTambah);
    jmnOps.add(jmiTolak);
    jmnOps.addSeparator();
    jmnOps.add(jmiDarab);
    jmnOps.add(jmiBahagi);
    jmiKeluar.setIcon(new ImageIcon("C:/gambar/keluar.gif"));

    jmnFail.setMnemonic('F');
    jmnOps.setMnemonic('O');
    jmiKeluar.setMnemonic('K');
    jmiTambah.setMnemonic('M');
    jmiTolak.setMnemonic('T');
    jmiDarab.setMnemonic('D');
    jmiBahagi.setMnemonic('B');

    jbtTambah.setToolTipText("Adding Number");
    jbtTolak.setToolTipText("Substracting Number");
    jbtDarab.setToolTipText("Multiplying Number");
    jbtBahagi.setToolTipText("Dividing Number");

    JPanel jplInput = new JPanel();
    jplInput.setLayout(new GridLayout(2,2));
    jplInput.add(jlbNo1);
    jplInput.add(jtfNo1);
    jplInput.add(jlbNo2);
    jplInput.add(jtfNo2);
    jplInput.setBackground(Color.pink);
    jlbNo1.setForeground(Color.white);
    jlbNo2.setForeground(Color.white);
    jlbNo1.setFont(new Font("Arial",Font.BOLD,20));
    jlbNo2.setFont(new Font("Arial",Font.BOLD,20));
    jlbResult.setFont(new Font("Arial",Font.BOLD,20));

    JPanel jplButang = new JPanel();
    jplButang.setLayout(new GridLayout(1,4,20,20));
    jplButang.add(jbtTambah);
    jplButang.add(jbtTolak);
    jplButang.add(jbtDarab);
    jplButang.add(jbtBahagi);
    jbtTambah.setIcon(new ImageIcon("C:/gambar/tambah.gif"));
    jbtTolak.setIcon(new ImageIcon("C:/gambar/tolak.gif"));
    jbtDarab.setIcon(new ImageIcon("C:/gambar/darab.gif"));
    jbtBahagi.setIcon(new ImageIcon("C:/gambar/bahagi.gif"));
    jbtTambah.setBackground(Color.yellow);
    jbtTolak.setBackground(Color.pink);
    jbtDarab.setBackground(Color.cyan);
    jbtBahagi.setBackground(Color.magenta);

    JPanel jplResult = new JPanel();
    jplResult.setLayout(new BorderLayout());
    jplResult.add(jlbResult,BorderLayout.WEST);
    jplResult.add(jtfResult,BorderLayout.CENTER);
    //jplResult.add(jtaOutput,BorderLayout.SOUTH);

    bekas.add(jplInput, BorderLayout.NORTH);
    bekas.add(jplButang, BorderLayout.CENTER);
    bekas.add(jplResult, BorderLayout.SOUTH);


    //Register
    jtfNo1.addActionListener(this);
    jtfNo2.addActionListener(this);
    jtfResult.addActionListener(this);

    jbtTambah.addActionListener(this);
    jbtTolak.addActionListener(this);
    jbtDarab.addActionListener(this);
    jbtBahagi.addActionListener(this);

    jmiKeluar.addActionListener(this);
    jmiTambah.addActionListener(this);
    jmiTolak.addActionListener(this);
    jmiDarab.addActionListener(this);
    jmiBahagi.addActionListener(this);
    }

    public void actionPerformed(ActionEvent e)
    {
    int n1,n2,hasil=0;

    if(e.getSource()==jbtTambah || e.getSource()==jmiTambah)
    {
    n1=Integer.parseInt(jtfNo1.getText().trim());
    n2=Integer.parseInt(jtfNo2.getText().trim());
    hasil=n1+n2;
    jtfResult.setText(new Integer(hasil).toString());
    }

    if(e.getSource()==jbtTolak || e.getSource()==jmiTolak)
    {
    n1=Integer.parseInt(jtfNo1.getText().trim());
    n2=Integer.parseInt(jtfNo2.getText().trim());
    hasil=n1-n2;
    jtfResult.setText(new Integer(hasil).toString());
    }

    if(e.getSource()==jbtDarab || e.getSource()==jmiDarab)
    {
    n1=Integer.parseInt(jtfNo1.getText().trim());
    n2=Integer.parseInt(jtfNo2.getText().trim());
    hasil=n1*n2;
    jtfResult.setText(new Integer(hasil).toString());
    }

    if(e.getSource()==jbtBahagi || e.getSource()==jmiBahagi)
    {
    n1=Integer.parseInt(jtfNo1.getText().trim());
    n2=Integer.parseInt(jtfNo2.getText().trim());
    hasil=n1/n2;
    jtfResult.setText(new Integer(hasil).toString());
    }

    if(e.getSource()==jmiKeluar)
    System.exit(0);

    }


    public static void main(String args[])
    {
    myCalculator bingkai = new myCalculator();
    bingkai.setTitle("KALKULATOR SAYA");
    bingkai.setSize(500,400);
    bingkai.setVisible(true);
    bingkai.setDefaultCloseOperation(bingkai.EXIT_ON_C LOSE);

    }
    }

    then i change it to executable jar. i want to run it by calling from html/jsp.
    Last edited by Zahari; 12-06-2007 at 12:07 AM.

Similar Threads

  1. executable
    By smooth in forum New To Java
    Replies: 4
    Last Post: 06-14-2008, 05:12 PM
  2. Executable Java
    By eva in forum New To Java
    Replies: 3
    Last Post: 12-30-2007, 11:38 PM
  3. Executable JAR
    By bugger in forum New To Java
    Replies: 4
    Last Post: 12-05-2007, 05:41 PM
  4. how to call a JAR FILE from HTML
    By leonard in forum Java Applets
    Replies: 1
    Last Post: 08-05-2007, 06:06 AM
  5. Executable Application, use JCreator
    By baltimore in forum New To Java
    Replies: 1
    Last Post: 07-31-2007, 06:03 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
  •