Results 1 to 3 of 3

Thread: .jar file

  1. #1
    RMW's Avatar
    RMW
    RMW is offline Member
    Join Date
    May 2011
    Location
    Sri Lanka
    Posts
    2
    Rep Power
    0

    Default .jar file

    How can I make a .jar file from this .java file? That is a little calculator designed by me.

    Java Code:
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    
    class Cal extends JFrame implements ActionListener{
    
    	Button b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,bAdd,bSub,bMul,bDev,bEq,bClear,bSta,bAve,bSum,bs,bDat,bFE,bdms,bsin,bcos,btan,bBra1,bExp,bxy,bx3,bx2,bBra2,bIn,blog,bn,b1x,bMC,bMR,bMS,bMpos,bPi,bA,bPosNeg,bB,bDot,bC,bD,bMod,bOr,bLsh,bE,bAnd,bXor,bNot,bInt,bF,bCE,bBack;	
    	TextField t1;
    	String st="",s1,lab;
    	String s;
    	double op,d;
    	Calculations dv;
    
    	Cal(){
    		setSize(490,322);
    		setTitle("Java Scientific Calculator - All Rights Reserved  RMW");
    
    	//------Menu Bar------------------------------------
    
    		MenuBar menuBar = new MenuBar();
    		setMenuBar(menuBar);
    
    		Menu editMenu = new Menu("Edit");
    		Menu viewMenu = new Menu("View");
    		Menu helpMenu = new Menu("Help");
    		menuBar.add(editMenu);
    		menuBar.add(viewMenu);
    		menuBar.add(helpMenu);
    
    		MenuItem mi1 = new MenuItem("Copy      Ctrl+C");
    		editMenu.add(mi1);
    		MenuItem mi2 = new MenuItem("Paste     Ctrl+V");
    		editMenu.add(mi2);
    
    		MenuItem mi3 = new MenuItem("Standard");
    		viewMenu.add(mi3);
    		MenuItem mi4 = new MenuItem("Scientific");
    		viewMenu.add(mi4);
    		MenuItem mi5 = new MenuItem("Hex                    F5");
    		viewMenu.add(mi5);
    		MenuItem mi6 = new MenuItem("Decimal            F6");
    		viewMenu.add(mi6);
    		MenuItem mi7 = new MenuItem("Octal                  F7");
    		viewMenu.add(mi7);
    		MenuItem mi8 = new MenuItem("Binary                F8");
    		viewMenu.add(mi8);
    		MenuItem mi9 = new MenuItem("Degrees           F2");
    		viewMenu.add(mi9);
    		MenuItem mi10 = new MenuItem("Radians           F3");
    		viewMenu.add(mi10);
    		MenuItem mi11 = new MenuItem("Grads                F3");
    		viewMenu.add(mi11);
    		MenuItem mi12 = new MenuItem("Digit Grouping");
    		viewMenu.add(mi12);
    
    		MenuItem mi13 = new MenuItem("Help Topics");
    		helpMenu.add(mi13);
    		MenuItem mi14 = new MenuItem("About Java Calculator");
    		helpMenu.add(mi14);
    
    	//------Panels--------------------------------------
    
    		BorderLayout bl = new BorderLayout();
    
    		Panel p1 = new Panel();
    		Panel p2 = new Panel();
    
    		p2.setLayout(null);
    
    		add(p1,bl.NORTH);
    		add(p2,bl.CENTER);
    
    		t1 = new TextField(62);		
    		p1.add(t1);
    
    		JPanel jp1 = new JPanel();
    		jp1.setBounds(143,31,26,26);
    		jp1.setBorder(BorderFactory.createLoweredBevelBorder());
    		p2.add(jp1);
    
    		JPanel jp2 = new JPanel();
    		jp2.setBounds(188,31,26,26);
    		jp2.setBorder(BorderFactory.createLoweredBevelBorder());
    		p2.add(jp2);
    
    	//------Column 01-----------------------------------
    
    		bSta = new Button("Sta");
    		bSta.setBounds(8,68,35,28);
    		bSta.setForeground(new Color(0,0,255));
    		p2.add(bSta);
    
    		bAve = new Button("Ave");
    		bAve.setBounds(8,100,35,28);
    		bAve.setForeground(new Color(0,0,0));
    		bAve.setEnabled(false);
    		p2.add(bAve);
    
    		bSum = new Button("Sum");
    		bSum.setBounds(8,132,35,28);
    		bSum.setForeground(new Color(0,0,0));
    		bSum.setEnabled(false);
    		p2.add(bSum);
    
    		bs = new Button("s");
    		bs.setBounds(8,164,35,28);
    		bs.setForeground(new Color(0,0,0));
    		bs.setEnabled(false);
    		p2.add(bs);
    
    		bDat = new Button("Dat");
    		bDat.setBounds(8,196,35,28);
    		bDat.setForeground(new Color(0,0,0));
    		bDat.setEnabled(false);
    		p2.add(bDat);
    
    	//------Column 02-----------------------------------
    
    		bFE = new Button("F-E");
    		bFE.setBounds(56,68,35,28);
    		bFE.setForeground(new Color(208,32,144));
    		p2.add(bFE);
    
    		bdms = new Button("dms");
    		bdms.setBounds(56,100,35,28);
    		bdms.setForeground(new Color(208,32,144));
    		p2.add(bdms);
    
    		bsin = new Button("sin");
    		bsin.setBounds(56,132,35,28);
    		bsin.setForeground(new Color(208,32,144));
    		p2.add(bsin);
    
    		bcos = new Button("cos");
    		bcos.setBounds(56,164,35,28);
    		bcos.setForeground(new Color(208,32,144));
    		p2.add(bcos);
    
    		btan = new Button("tan");
    		btan.setBounds(56,196,35,28);
    		btan.setForeground(new Color(208,32,144));
    		p2.add(btan);
    
    	//------Column 03-----------------------------------
    
    		bBra1 = new Button("(");
    		bBra1.setBounds(96,68,35,28);
    		bBra1.setForeground(new Color(208,32,144));
    		p2.add(bBra1);
    
    		bExp = new Button("Exp");
    		bExp.setBounds(96,100,35,28);
    		bExp.setForeground(new Color(208,32,144));
    		p2.add(bExp);
    
    		bxy = new Button("x^y");
    		bxy.setBounds(96,132,35,28);
    		bxy.setForeground(new Color(208,32,144));
    		p2.add(bxy);
    
    		bx3 = new Button("x^3");
    		bx3.setBounds(96,164,35,28);
    		bx3.setForeground(new Color(208,32,144));
    		p2.add(bx3);
    
    		bx2 = new Button("x^2");
    		bx2.setBounds(96,196,35,28);
    		bx2.setForeground(new Color(208,32,144));
    		p2.add(bx2);
    
    	//------Column 04-----------------------------------
    
    		bBra2 = new Button(")");
    		bBra2.setBounds(136,68,35,28);
    		bBra2.setForeground(new Color(208,32,144));
    		p2.add(bBra2);
    
    		bIn = new Button("In");
    		bIn.setBounds(136,100,35,28);
    		bIn.setForeground(new Color(208,32,144));
    		p2.add(bIn);
    
    		blog = new Button("log");
    		blog.setBounds(136,132,35,28);
    		blog.setForeground(new Color(208,32,144));
    		p2.add(blog);
    
    		bn = new Button("n!");
    		bn.setBounds(136,164,35,28);
    		bn.setForeground(new Color(208,32,144));
    		p2.add(bn);
    
    		b1x = new Button("1/x");
    		b1x.setBounds(136,196,35,28);
    		b1x.setForeground(new Color(208,32,144));
    		p2.add(b1x);
    
    	//------Column 05-----------------------------------
    
    		bMC = new Button("MC");
    		bMC.setBounds(184,68,35,28);
    		bMC.setForeground(new Color(255,0,0));
    		p2.add(bMC);
    
    		bMR = new Button("MR");
    		bMR.setBounds(184,100,35,28);
    		bMR.setForeground(new Color(255,0,0));
    		p2.add(bMR);
    
    		bMS = new Button("MS");
    		bMS.setBounds(184,132,35,28);
    		bMS.setForeground(new Color(255,0,0));
    		p2.add(bMS);
    
    		bMpos = new Button("M+");
    		bMpos.setBounds(184,164,35,28);
    		bMpos.setForeground(new Color(255,0,0));
    		p2.add(bMpos);
    
    		bPi = new Button("Pi");
    		bPi.setBounds(184,196,35,28);
    		bPi.setForeground(new Color(0,0,255));
    		p2.add(bPi);
    
    	//------Column 06-----------------------------------
    
    		b7 = new Button("7");
    		b7.setBounds(232,68,35,28);
    		b7.setForeground(new Color(0,0,255));
    		p2.add(b7);
    
    		b4 = new Button("4");
    		b4.setBounds(232,100,35,28);
    		b4.setForeground(new Color(0,0,255));
    		p2.add(b4);
    
    		b1 = new Button("1");
    		b1.setBounds(232,132,35,28);
    		b1.setForeground(new Color(0,0,255));
    		p2.add(b1);
    
    		b0 = new Button("0");
    		b0.setBounds(232,164,35,28);
    		b0.setForeground(new Color(0,0,255));
    		p2.add(b0);
    
    		bA = new Button("A");
    		bA.setBounds(232,196,35,28);
    		bA.setForeground(new Color(0,0,0));
    		bA.setEnabled(false);
    		p2.add(bA);
    
    	//------Column 07-----------------------------------
    
    		b8 = new Button("8");
    		b8.setBounds(272,68,35,28);
    		b8.setForeground(new Color(0,0,255));
    		p2.add(b8);
    
    		b5 = new Button("5");
    		b5.setBounds(272,100,35,28);
    		b5.setForeground(new Color(0,0,255));
    		p2.add(b5);
    
    		b2 = new Button("2");
    		b2.setBounds(272,132,35,28);
    		b2.setForeground(new Color(0,0,255));
    		p2.add(b2);
    
    		bPosNeg = new Button("+/-");
    		bPosNeg.setBounds(272,164,35,28);
    		bPosNeg.setForeground(new Color(0,0,255));
    		p2.add(bPosNeg);
    
    		bB = new Button("B");
    		bB.setBounds(272,196,35,28);
    		bB.setForeground(new Color(0,0,0));
    		bB.setEnabled(false);
    		p2.add(bB);
    
    
    	//------Column 08-----------------------------------
    
    		b9 = new Button("9");
    		b9.setBounds(312,68,35,28);
    		b9.setForeground(new Color(0,0,255));
    		p2.add(b9);
    
    		b6 = new Button("6");
    		b6.setBounds(312,100,35,28);
    		b6.setForeground(new Color(0,0,255));
    		p2.add(b6);
    
    		b3 = new Button("3");
    		b3.setBounds(312,132,35,28);
    		b3.setForeground(new Color(0,0,255));
    		p2.add(b3);
    
    		bDot = new Button(".");
    		bDot.setBounds(312,164,35,28);
    		bDot.setForeground(new Color(0,0,255));
    		p2.add(bDot);
    
    		bC = new Button("C");
    		bC.setBounds(312,196,35,28);
    		bC.setForeground(new Color(0,0,0));
    		bC.setEnabled(false);
    		p2.add(bC);
    
    	//------Column 09-----------------------------------
    
    		bDev = new Button("/");
    		bDev.setBounds(352,68,35,28);
    		bDev.setForeground(new Color(255,0,0));
    		p2.add(bDev);
    
    		bMul = new Button("*");
    		bMul.setBounds(352,100,35,28);
    		bMul.setForeground(new Color(255,0,0));
    		p2.add(bMul);
    
    		bSub = new Button("-");
    		bSub.setBounds(352,132,35,28);
    		bSub.setForeground(new Color(255,0,0));
    		p2.add(bSub);
    
    		bAdd = new Button("+");
    		bAdd.setBounds(352,164,35,28);
    		bAdd.setForeground(new Color(255,0,0));
    		p2.add(bAdd);
    
    		bD = new Button("D");
    		bD.setBounds(352,196,35,28);
    		bD.setForeground(new Color(0,0,0));
    		bD.setEnabled(false);
    		p2.add(bD);
    
    	//------Column 10-----------------------------------
    
    		bMod = new Button("Mod");
    		bMod.setBounds(392,68,35,28);
    		bMod.setForeground(new Color(255,0,0));
    		p2.add(bMod);
    
    		bOr = new Button("Or");
    		bOr.setBounds(392,100,35,28);
    		bOr.setForeground(new Color(255,0,0));
    		p2.add(bOr);
    
    		bLsh = new Button("Lsh");
    		bLsh.setBounds(392,132,35,28);
    		bLsh.setForeground(new Color(255,0,0));
    		p2.add(bLsh);
    
    		bEq = new Button("=");
    		bEq.setBounds(392,164,35,28);
    		bEq.setForeground(new Color(255,0,0));
    		p2.add(bEq);
    
    		bE = new Button("E");
    		bE.setBounds(392,196,35,28);
    		bE.setForeground(new Color(0,0,0));
    		bE.setEnabled(false);
    		p2.add(bE);
    
    	//------Column 11-----------------------------------
    
    		bAnd = new Button("And");
    		bAnd.setBounds(432,68,35,28);
    		bAnd.setForeground(new Color(255,0,0));
    		p2.add(bAnd);
    
    		bXor = new Button("Xor");
    		bXor.setBounds(432,100,35,28);
    		bXor.setForeground(new Color(255,0,0));
    		p2.add(bXor);
    
    		bNot = new Button("Not");
    		bNot.setBounds(432,132,35,28);
    		bNot.setForeground(new Color(255,0,0));
    		p2.add(bNot);
    
    		bInt = new Button("Int");
    		bInt.setBounds(432,164,35,28);
    		bInt.setForeground(new Color(255,0,0));
    		p2.add(bInt);
    
    		bF = new Button("F");
    		bF.setBounds(432,196,35,28);
    		bF.setForeground(new Color(0,0,0));
    		bF.setEnabled(false);
    		p2.add(bF);
    
    	//------Row 01-----------------------------------
    
    		JRadioButton rb1 = new JRadioButton("Hex");
    		rb1.setBounds(9,3,50,20);
    		p2.add(rb1);
    
    		JRadioButton rb2 = new JRadioButton("Dec");
    		rb2.setBounds(59,3,51,20);
    		p2.add(rb2);
    
    		JRadioButton rb3 = new JRadioButton("Oct");
    		rb3.setBounds(109,3,51,20);
    		p2.add(rb3);
    
    		JRadioButton rb4 = new JRadioButton("Bin");
    		rb4.setBounds(158,3,51,20);
    		p2.add(rb4);
    
    		JRadioButton rb5 = new JRadioButton("Degrees");
    		rb5.setBounds(226,3,80,20);
    		p2.add(rb5);
    
    		JRadioButton rb6 = new JRadioButton("Radians");
    		rb6.setBounds(305,3,80,20);
    		p2.add(rb6);
    
    		JRadioButton rb7 = new JRadioButton("Grads");
    		rb7.setBounds(384,3,80,20);
    		p2.add(rb7);
    
    		JPanel jp3 = new JPanel();
    		jp3.setBounds(8,0,215,26);
    		jp3.setBorder(BorderFactory.createEtchedBorder());
    		p2.add(jp3);
    
    		JPanel jp4 = new JPanel();
    		jp4.setBounds(224,0,244,26);
    		jp4.setBorder(BorderFactory.createEtchedBorder());
    		p2.add(jp4);
    
    	//------Row 02-----------------------------------
    
    		bClear = new Button("C");
    		bClear.setBounds(402,31,65,28);
    		bClear.setForeground(new Color(255,0,0));
    		p2.add(bClear);
    
    		bCE = new Button("CE");
    		bCE.setBounds(333,31,65,28);
    		bCE.setForeground(new Color(255,0,0));
    		p2.add(bCE);
    
    		bBack = new Button("Backspace");
    		bBack.setBounds(264,31,65,28);
    		bBack.setForeground(new Color(255,0,0));
    		p2.add(bBack);
    
    		Checkbox cb1 = new Checkbox("lnv");
    		cb1.setBounds(12,35,50,20);
    		p2.add(cb1);
    
    		Checkbox cb2 = new Checkbox("Hyp");
    		cb2.setBounds(72,35,50,20);
    		p2.add(cb2);
    
    		JPanel jp5 = new JPanel();
    		jp5.setBounds(8,31,129,26);
    		jp5.setBorder(BorderFactory.createEtchedBorder());
    		p2.add(jp5);
    
    		b0.addActionListener(this);
    		b1.addActionListener(this);
    		b2.addActionListener(this);
    		b3.addActionListener(this);
    		b4.addActionListener(this);
    		b5.addActionListener(this);
    		b6.addActionListener(this);
    		b7.addActionListener(this);
    		b8.addActionListener(this);
    		b9.addActionListener(this);
    		bClear.addActionListener(this);
    		bAdd.addActionListener(this);
    		bSub.addActionListener(this);
    		bMul.addActionListener(this);
    		bDev.addActionListener(this);
    		bEq.addActionListener(this);
    
    //----------------------------------------------------------
    
    		setVisible(true);
    		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    
    //----------------------------------------------------------
    
    	}
    
    	public void actionPerformed(ActionEvent e){
    
    		Object o = e.getSource();
    
    		if(o.equals(b0)){
    			s=b0.getLabel();
    			st=st+s;
    			t1.setText(st);
    		}
    
    		else if(o.equals(b1)){
    			s=b1.getLabel();
    			st=st+s;
    			t1.setText(st);
    		}
    
    		else if(o.equals(b2)){
    			s=b2.getLabel();
    			st=st+s;
    			t1.setText(st);
    		}
    
    		else if(o.equals(b3)){
    			s=b3.getLabel();
    			st=st+s;
    			t1.setText(st);
    		}
    
    		else if(o.equals(b4)){
    			s=b4.getLabel();
    			st=st+s;
    			t1.setText(st);
    		}
    
    		else if(o.equals(b5)){
    			s=b5.getLabel();
    			st=st+s;
    			t1.setText(st);
    		}
    
    		else if(o.equals(b6)){
    			s=b6.getLabel();
    			st=st+s;
    			t1.setText(st);
    		}
    
    
    		else if(o.equals(b7)){
    			s=b7.getLabel();
    			st=st+s;
    			t1.setText(st);
    		}
    
    
    		else if(o.equals(b8)){
    			s=b8.getLabel();
    			st=st+s;
    			t1.setText(st);
    		}
    
    
    		else if(o.equals(b9)){
    			s=b9.getLabel();
    			st=st+s;
    			t1.setText(st);
    		}
    
    
    		else if(o.equals(bClear)){
    			s=bClear.getLabel();
    			st="";
    			t1.setText(st);
    		}
    
    		else if(o.equals(bAdd)){
    			s1=t1.getText();
    			d=Double.parseDouble(s1);
    			op=op+d;
    			lab=bAdd.getLabel();
    			st="";
    			t1.setText(st);
    		}
    
    		else if(o.equals(bSub)){
    			s1=t1.getText();
    			d=Double.parseDouble(s1);
    			op=d;
    			lab=bSub.getLabel();
    			st="";
    			t1.setText(st);
    		}
    
    		else if(o.equals(bMul)){
    			s1=t1.getText();
    			d=Double.parseDouble(s1);
    			op=d;
    			lab=bMul.getLabel();
    			st="";
    			t1.setText(st);
    		}
    
    		else if(o.equals(bDev)){
    			s1=t1.getText();
    			d=Double.parseDouble(s1);
    			op=d;
    			lab=bDev.getLabel();
    			st="";
    			t1.setText(st);
    		}
    
    		else if(o.equals(bEq)){
    			s1=t1.getText();
    			d=Integer.parseInt(s1);
    			dv = new Calculations();
    
    			if(lab.equals("+")){
    				dv.adding(op,d,t1);
    				op=0;
    			}
    
    			if(lab.equals("-")){
    				dv.substracting(op,d,t1);
    			}
    
    			if(lab.equals("*")){
    				dv.multiplying(op,d,t1);
    			}
    
    			if(lab.equals("/")){
    				dv.deviding(op,d,t1);
    				op=0;
    			}
    		}
    	}
    }
    
    class CreateCal{
    
    	public static void main(String args[]){
    
    		Cal c = new Cal();
    	}
    
    }
    
    class Calculations{
    
    	double a,b,tot;
    	TextField t;
    
    	void adding(double a,double b,TextField t){
    
    		this.b=b;
    		this.a=a;
    		this.t=t;
    		tot=a+b;
    
    		t.setText(""+tot);
    	
    	}
    
    	void substracting(double a,double b,TextField t){
    
    		this.b=b;
    		this.a=a;
    		this.t=t;
    		tot=a-b;
    
    		t.setText(""+tot);
    	
    	}
    
    	void multiplying(double a,double b,TextField t){
    
    		this.b=b;
    		this.a=a;
    		this.t=t;
    		tot=a*b;
    
    		t.setText(""+tot);
    	
    	}
    
    	void deviding(double a,double b,TextField t){
    
    		this.b=b;
    		this.a=a;
    		this.t=t;
    		tot=a/b;
    
    		t.setText(""+tot);	
    	}
    }

  2. #2
    RMW's Avatar
    RMW
    RMW is offline Member
    Join Date
    May 2011
    Location
    Sri Lanka
    Posts
    2
    Rep Power
    0

    Default

    Someone please help me...

  3. #3
    shazam's Avatar
    shazam is offline Member
    Join Date
    Jan 2011
    Location
    USA, CA
    Posts
    9
    Rep Power
    0

    Default

    I have not done this myself but I found a tutorial at oracle

    Packaging JAR Files
    Java Newbie

Similar Threads

  1. Replies: 6
    Last Post: 12-01-2010, 06:31 AM
  2. Replies: 1
    Last Post: 08-04-2010, 04:24 PM
  3. Replies: 0
    Last Post: 07-15-2010, 02:23 PM
  4. Replies: 0
    Last Post: 02-11-2009, 10:53 AM
  5. Replies: 7
    Last Post: 05-23-2008, 04:46 AM

Tags for this Thread

Posting Permissions

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