7 Replies - 1702 Views - Last Post: 12 May 2012 - 06:56 PM Rate Topic: -----

#1 tawilovejessicalawrent   User is offline

  • D.I.C Head

Reputation: -11
  • View blog
  • Posts: 122
  • Joined: 08-April 12

How can we compile a java file and create an exe file with Java file?

Posted 08 April 2012 - 06:30 AM

Can any folks help? One more question, can we use .jar directly at our cellular phone?
Is This A Good Question/Topic? 0
  • +

Replies To: How can we compile a java file and create an exe file with Java file?

#2 ILoveJava   User is offline

  • D.I.C Regular

Reputation: 29
  • View blog
  • Posts: 389
  • Joined: 12-March 12

Re: How can we compile a java file and create an exe file with Java file?

Posted 08 April 2012 - 06:37 AM

.java/.class files aren't turned into .exe's. they are turned into executable .jar files. I'm sure you can find many tutorials on the internet.
Was This Post Helpful? 0
  • +
  • -

#3 Ryano121   User is offline

  • D.I.C Lover
  • member icon

Reputation: 1461
  • View blog
  • Posts: 3,289
  • Joined: 30-January 11

Re: How can we compile a java file and create an exe file with Java file?

Posted 08 April 2012 - 06:54 AM

ILoveJava is correct in that java can compile into executable .jar files.

However with the help of a third party program such as Launch4j, you can turn your existing executable .jar files into native windows executables (.exe).

Some reading
Was This Post Helpful? 0
  • +
  • -

#4 tawilovejessicalawrent   User is offline

  • D.I.C Head

Reputation: -11
  • View blog
  • Posts: 122
  • Joined: 08-April 12

Re: How can we compile a java file and create an exe file with Java file?

Posted 08 April 2012 - 09:07 AM

Well, can we use this .jar in our cellular phone after we copy it to our cellular phone without using any things else?
Was This Post Helpful? 0
  • +
  • -

#5 Ryano121   User is offline

  • D.I.C Lover
  • member icon

Reputation: 1461
  • View blog
  • Posts: 3,289
  • Joined: 30-January 11

Re: How can we compile a java file and create an exe file with Java file?

Posted 08 April 2012 - 11:37 AM

Depends, what 'cellular phone' are you using and what OS does it run?
Was This Post Helpful? 0
  • +
  • -

#6 tawilovejessicalawrent   User is offline

  • D.I.C Head

Reputation: -11
  • View blog
  • Posts: 122
  • Joined: 08-April 12

Re: How can we compile a java file and create an exe file with Java file?

Posted 11 May 2012 - 07:22 PM

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package programserverpemilihanobat;

/**
 *
 * @author Tawi
 */
import javax.swing.*;
import javax.swing.JFrame;
import javax.sql.*;
import java.awt.event.*;
import java.awt.*;
import java.sql.*;
import java.util.*;
import javax.swing.JLabel;
import javax.swing.JTextField;
import java.awt.GridLayout;

public class ProgramServerPemilihanObat extends JFrame {

    /**
     * @param args the command line arguments
     */
 public MasukkanKriteriaAlternatifObat() {
    setLayout(new GridLayout (0,0,5,0));
    add(new JLabel("Pemilihan Obat"));
    JLabel label2 = new JLabel("Harga/Efek Samping");
    JLabel label3 = new JLabel("Harga/Kualitas");
    JLabel label4 = new JLabel("Harga/Ketersediaan");
    JLabel label5 = new JLabel("Efek Samping/Kualitas");
    JLabel label6 = new JLabel("Efek Samping/Ketersediaan");
    JLabel label7 = new JLabel("Ketersediaan/Kualitas");
    JLabel labelo1 = new JLabel("Harga Naproxen/Harga Ibuprofen");
    JLabel labelo2 = new JLabel("Harga Naproxen/Harga Na-Diklofenac");
    JLabel labelo3 = new JLabel("Harga Naproxen/Harga Celecoxib");
    JLabel labelo4 = new JLabel("Harga Naproxen/Harga Etoricoxib");
    JLabel labelo5 = new JLabel("Harga Ibuprofen/Harga Na-Diklofenac");
    JLabel labelo6 = new JLabel("Harga Ibuprofen/Harga Celecoxib");
    JLabel labelo7 = new JLabel("Harga Ibuprofen/Harga Etoricoxib");
    JLabel labelo8 = new JLabel("Harga Na-Diklofenac/Harga Celecoxib");
    JLabel labelo9 = new JLabel("Harga Na-Diklofenac/Harga Etoricoxib");
    JLabel labelo10 = new JLabel("Harga Celecoxib/Harga Etoricoxib");
    JLabel labelo11 = new JLabel("Efek Samping Naproxen/Efek Samping Ibuprofen");
    JLabel labelo12 = new JLabel("Efek Samping Naproxen/Efek Samping Na-Diclofenac");
    JLabel labelo13 = new JLabel("Efek Samping Naproxen/Efek Samping Celecoxib");
    JLabel labelo14 = new JLabel("Efek Samping Naproxen/Efek Samping Etoricoxib");
    JLabel labelo15 = new JLabel("Efek Samping Ibuprofen/Efek Samping Na-Diclofenac");
    JLabel labelo16 = new JLabel("Efek Samping Ibuprofen/Efek Samping Celecoxib");
    JLabel labelo17 = new JLabel("Efek Samping Ibuprofen/Efek Samping Etoricoxib");
    JLabel labelo18 = new JLabel("Efek Samping Na-Diclofenac/Efek Samping Celecoxib");
    JLabel labelo19 = new JLabel("Efek Samping Na-Diclofenac/Efek Samping Etoricoxib");
    JLabel labelo20 = new JLabel("Efek Samping Celecoxib/Efek Samping Etoricoxib");
    JLabel labelo21 = new JLabel("Kualitas Naproxen/Kualitas Ibuprofen");
    JLabel labelo22 = new JLabel("Kualitas Naproxen/Kualitas Na-Diclofenac");
    JLabel labelo23 = new JLabel("Kualitas Naproxen/Kualitas Celecoxib");
    JLabel labelo24 = new JLabel("Kualitas Naproxen/Kualitas Etoricoxib");
    JLabel labelo25 = new JLabel("Kualitas Ibuprofen/Kualitasa Na-Diclofenac");
    JLabel labelo26 = new JLabel("Kualitas Ibuprofen/Kualitas Celecoxib");
    JLabel labelo27 = new JLabel("Kualitas Ibuprofen/Kualitas Etoricoxib");
    JLabel labelo28 = new JLabel("Kualitas Na-Diclofenac/Kualitas Celecoxib");
    JLabel labelo29 = new JLabel("Kualitas Na-Diclofenac/Kualitas Etoricoxib");
    JLabel labelo30 = new JLabel("Kualits Celecoxib/Kualitas Etoricoxib");
    JLabel labelo31 = new JLabel("Ketersediaan Naproxen/Ketersediaan Ibuprofen");
    JLabel labelo32 = new JLabel("Ketersediaan Naproxen/Ketersediaan Na-Diclofenac");
    JLabel labelo33 = new JLabel("Ketersediaan Naproxen/Ketersediaan Celecoxib");
    JLabel labelo34 = new JLabel("Ketersediaan Naproxen/Ketersediaan Etoricoxib");
    JLabel labelo35 = new JLabel("Ketersediaan Ibuprofen/Ketersediaan Na-Diclofenac");
    JLabel labelo36 = new JLabel("Ketersediaan Ibuprofen/Ketersediaan Celecoxib");
    JLabel labelo37 = new JLabel("Ketersediaan Ibuprofen/Ketersediaan Etoricoxib");
    JLabel labelo38 = new JLabel("Ketersediaan Na-Diclofenac/Ketersediaan Celecoxib");
    JLabel labelo39 = new JLabel("Ketersediaan Na-Diclofenac/Ketersediaan Etoricoxib");
    JLabel labelo40 = new JLabel("Ketersediaan Celecoxib/Ketersediaan Etoricoxib");
    JTextField inputNilai1 = new JTextField(2);
    JTextField inputNilai2 = new JTextField(2);
    JTextField inputNilai3 = new JTextField(2);
    JTextField inputNilai4 = new JTextField(2);
    JTextField inputNilai5 = new JTextField(2);
    JTextField inputNilai6 = new JTextField(2);
    JTextField inputNilai7 = new JTextField(2);
    JTextField inputNilai8 = new JTextField(2);
    JTextField inputNilai9 = new JTextField(2);
    JTextField inputNilai10 = new JTextField(2);
    JTextField inputNilai11 = new JTextField(2);
    JTextField inputNilai12 = new JTextField(2);
    JTextField inputNilai13 = new JTextField(2);
    JTextField inputNilai14 = new JTextField(2);
    JTextField inputNilai15 = new JTextField(2);
    JTextField inputNilai16 = new JTextField(2);
    JTextField inputNilai17 = new JTextField(2);
    JTextField inputNilai18 = new JTextField(2);
    JTextField inputNilai19 = new JTextField(2);
    JTextField inputNilai20 = new JTextField(2);
    JTextField inputNilai21 = new JTextField(2);
    JTextField inputNilai22 = new JTextField(2);
    JTextField inputNilai23 = new JTextField(2);
    JTextField inputNilai24 = new JTextField(2);
    JTextField inputNilai25 = new JTextField(2);
    JTextField inputNilai26 = new JTextField(2);
    JTextField inputNilai27 = new JTextField(2);
    JTextField inputNilai28 = new JTextField(2);
    JTextField inputNilai29 = new JTextField(2);
    JTextField inputNilai30 = new JTextField(2);
    JTextField inputNilai31 = new JTextField(2);
    JTextField inputNilai32 = new JTextField(2);
    JTextField inputNilai33 = new JTextField(2);
    JTextField inputNilai34 = new JTextField(2);
    JTextField inputNilai35 = new JTextField(2);
    JTextField inputNilai36 = new JTextField(2);
    JTextField inputNilai37 = new JTextField(2);
    JTextField inputNilai38 = new JTextField(2);
    JTextField inputNilai39 = new JTextField(2);
    JTextField inputNilai40 = new JTextField(2);
    JTextField inputNilai41 = new JTextField(2);
    JTextField inputNilai42 = new JTextField(2);
    JTextField inputNilai43 = new JTextField(2);
    JTextField inputNilai44 = new JTextField(2);
    JTextField inputNilai45 = new JTextField(2);
    JTextField inputNilai46 = new JTextField(2);
    setLayout(new GridLayout (5,0,5,0));
    add(inputNilai1.add(label2));
    setLayout(new GridLayout (10,0,5,0));
    add(inputNilai2.add(label3));
    setLayout(new GridLayout (15,0,5,0));
    add(inputNilai3.add(label4));
    setLayout(new GridLayout (20,0,5,0));
    add(inputNilai4.add(label5));
    setLayout(new GridLayout (25,0,5,0));
    add(inputNilai5.add(label6));
    setLayout(new GridLayout (30,0,5,0));
    add(inputNilai6.add(label7));
    /**
    add(inputNilai7.add(labelo1));
    add(inputNilai8.add(labelo2));
    add(inputNilai9.add(labelo3));
    add(inputNilai10.add(labelo4));
    add(inputNilai11.add(labelo5));  
    add(inputNilai12.add(labelo6));
    add(inputNilai13.add(labelo7));
    add(inputNilai14.add(labelo8));
    add(inputNilai15.add(labelo9));
    add(inputNilai16.add(labelo10));
    add(inputNilai17.add(labelo11));
    add(inputNilai18.add(labelo12));
    add(inputNilai19.add(labelo13));
    add(inputNilai20.add(labelo14));
    add(inputNilai21.add(labelo15));  
    add(inputNilai22.add(labelo16));
    add(inputNilai23.add(labelo17));
    add(inputNilai24.add(labelo18));
    add(inputNilai25.add(labelo19));
    add(inputNilai26.add(labelo20));
    add(inputNilai27.add(labelo21));
    add(inputNilai28.add(labelo22));
    add(inputNilai29.add(labelo23));
    add(inputNilai30.add(labelo24));
    add(inputNilai31.add(labelo25));  
    add(inputNilai32.add(labelo26));
    add(inputNilai33.add(labelo27));
    add(inputNilai34.add(labelo28));
    add(inputNilai35.add(labelo29));
    add(inputNilai36.add(labelo30));
    add(inputNilai37.add(labelo31));
    add(inputNilai38.add(labelo32));
    add(inputNilai39.add(labelo33));
    add(inputNilai40.add(labelo34));
    add(inputNilai41.add(labelo35));  
    add(inputNilai42.add(labelo36));
    add(inputNilai43.add(labelo37));
    add(inputNilai44.add(labelo38));
    add(inputNilai45.add(labelo39));
    add(inputNilai46.add(labelo40)); */
 }   
    
    
public static void main(String[] args) {
        // TODO code application logic here
    JFrame frame1 = new JFrame();
        frame1.setTitle("Program Pemilihan Obat");
        frame1.setSize(1024,768);
        frame1.setLocation(0,0);
        frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame1.setVisible(true);

    }
        
}




What's wrong with this code? Why do I get a blank screen? I want to put some labels and some textfields, any folks can help?
Was This Post Helpful? 0
  • +
  • -

#7 macosxnerd101   User is offline

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12324
  • View blog
  • Posts: 45,424
  • Joined: 27-December 08

Re: How can we compile a java file and create an exe file with Java file?

Posted 11 May 2012 - 09:48 PM

Sweet mother of mercy! Learn how to use arrays! They will help simplify your life a lot.

Second, why do you keep changing the LayoutManager of the JFrame? And you are only adding certain JComponents to the JFrame.

Quote

Well, can we use this .jar in our cellular phone after we copy it to our cellular phone without using any things else?

No. Swing cannot be used on the mobile platform. If you want to work with Java on the mobile platform, Android is the way to go. Certain antiquated phones support Java ME as well.
Was This Post Helpful? 0
  • +
  • -

#8 tawilovejessicalawrent   User is offline

  • D.I.C Head

Reputation: -11
  • View blog
  • Posts: 122
  • Joined: 08-April 12

Re: How can we compile a java file and create an exe file with Java file?

Posted 12 May 2012 - 06:56 PM

I tried to use array but was failed, what should I do? After I finish this code, I want to make it to be an exe file, so? I want to use it to put my components because I am afraid that Java will put rest of it horizontally. I need to put some horizontally and the other in the next line, can any folks help?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1