This video will show you how to create Java jar application
and Java exe application using Eclipse and Launch4j.
Copy following java code and try it.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Student extends JFrame implements ActionListener
{
Student()
{
setTitle("Student");
addWindowListener(new WindowHandler());
Container cp=getContentPane();
cp.setBackground(Color.yellow);
cp.setLayout(new FlowLayout());
cp.add(new JLabel("Enter your first name"));
cp.add(first=new JTextField(20));
cp.add(new JLabel("Enter your middle name"));
cp.add(middle=new JTextField(20));
cp.add(new JLabel("Enter your last name"));
cp.add(last=new JTextField(20));
cp.add(new JLabel("Enter Rollno"));
cp.add(rollno=new JTextField(10));
cp.add(new JLabel("Enter your college name"));
cp.add(college=new JTextField(30));
cp.add(new JLabel("Enter marks for Computer Science"));
cp.add(comp=new JTextField(10));
cp.add(new JLabel("Enter marks for Physics"));
cp.add(phy=new JTextField(10));
cp.add(new JLabel("Enter marks for Electronics"));
cp.add(ele=new JTextField(10));
cp.add(new JLabel("Enter marks for Mathematics"));
cp.add(math=new JTextField(10));
name=new JLabel("---------------------------------------------------------------------------------------------------------");
rollno1=new JLabel("-------------------------------------------------------------------------------------------------------------");
collegename=new JLabel("---------------------------------------------------------------------------------------------------------------");
compmark=new JLabel("---------------------------------------------------------------------------------------------------------------");
phymark=new JLabel("----------------------------------------------------------------------------------------------------------------");
elemark=new JLabel("------------------------------------------------------------------------------------------------------------------");
mathmark=new JLabel("---------------------------------------------------------------------------------------------------------------------");
average=new JLabel("----------------------------------------------------------------------------------------------------------------------");
JButton done=new JButton("Done");
cp.add(done);
done.addActionListener(this);
cp.add(name);
cp.add(rollno1);
cp.add(collegename);
cp.add(compmark);
cp.add(phymark);
cp.add(elemark);
cp.add(mathmark);
cp.add(average);
}
public void actionPerformed(ActionEvent ev)
{
String firstname1=first.getText();
String middlename1=middle.getText();
String lastname1=last.getText();
String rollno2=rollno.getText();
String collegename1=college.getText();
String compmark2=comp.getText();
String phymark2=phy.getText();
String elemark2=ele.getText();
String mathmark2=math.getText();
float c=Float.parseFloat(compmark2);
float p=Float.parseFloat(phymark2);
float e=Float.parseFloat(elemark2);
float m=Float.parseFloat(mathmark2);
float total=(c+p+e+m)/400;
float avg=total*100;
name.setText("\nName="+firstname1+" "+middlename1+" "+lastname1+" ");
rollno1.setText("\nRollno="+rollno2+" ");
collegename.setText("\nCollege="+collegename1+" ");
compmark.setText("\nComputer Marks="+compmark2+" ");
phymark.setText("\nPhysics Marks="+phymark2+" ");
elemark.setText("\nElectronics Marks="+elemark2+" ");
mathmark.setText("\nMathematics Marks="+mathmark2+" ");
average.setText("\nAverage="+avg);
}
class WindowHandler extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
}
private JLabel name,middlename,lastname,rollno1,collegename,compmark,phymark,elemark,mathmark,average;
private JTextField first,middle,last,rollno,college,comp,phy,ele,math;
private JButton done;
public static void main (String args[])
{
JFrame jf=new Student();
jf.setSize(400,400);
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jf.setLocation(300,50);
jf.setVisible(true);
}
}
On this page of the site you can watch the video online How to create Java jar & exe application using Eclipse & Launch4j with a duration of hours minute second in good quality, which was uploaded by the user Pritam Zope 01 December 2014, share the link with friends and acquaintances, this video has already been watched 4,980 times on youtube and it was liked by 20 viewers. Enjoy your viewing!