5 Replies - 315 Views - Last Post: 01 October 2012 - 10:16 PM Rate Topic: -----

#1 hanzechin  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 01-October 12

Difficulties running the .jar files

Posted 01 October 2012 - 07:38 PM

After running my code in console I've deemed it worthy of exporting due to a somewhat bare but satisfying GUI in my opinion but I can't seem to be able to run my .jar file here is my piece of code I've assembled...and exported as a .jar file just .jar from the java not anything special other then that...

package sk.noodleartisianworkshop;

import java.text.DecimalFormat;
import javax.swing.JOptionPane;

public class NoodleWorkshop
{

	public static void main(String[] args)
	{

String flourPrice =JOptionPane.showInputDialog("What is the price per bag of flour?");
String woodPrice = JOptionPane.showInputDialog("What is the price per bushel of wood?");
String dailyWage = JOptionPane.showInputDialog("What is the daily wage you seek to obtain on a daily basis?");

double num1 = Double.parseDouble(flourPrice);
double num2 = Double.parseDouble(woodPrice);
double num3 = Double.parseDouble(dailyWage);
double pricePerUdon = (num1 * 12 + num2 * 6 + num3) / 36;
double afterTax = pricePerUdon * (1+.03);

DecimalFormat twoDecimals = new DecimalFormat(".00");
JOptionPane.showMessageDialog(null, "You should sell each bowl of Udon for " +  twoDecimals.format(pricePerUdon)  + ", although after tax the consumer shall be charged " + twoDecimals.format(afterTax) + " kobans." ); 
	}
	
}


Thanks in advance,
Zechin

Is This A Good Question/Topic? 0
  • +

Replies To: Difficulties running the .jar files

#2 fromTheSprawl  Icon User is offline

  • Monomania
  • member icon

Reputation: 513
  • View blog
  • Posts: 2,055
  • Joined: 28-December 10

Re: Difficulties running the .jar files

Posted 01 October 2012 - 08:02 PM

How do you run it? How do you export it? What's the error? I've successfully created a jar file of your program using Eclipse.
Was This Post Helpful? 1
  • +
  • -

#3 Kakerergodt  Icon User is offline

  • D.I.C Head

Reputation: 87
  • View blog
  • Posts: 201
  • Joined: 01-May 12

Re: Difficulties running the .jar files

Posted 01 October 2012 - 09:00 PM

If you're gonna create a jar with a simple commandline use of javas jar.exe then drop the line with package in it, and it runs fine.

Edit: it's ofcourse possible to get it to run with the package line without the use of an IDE like NetBeans or Eclipse, but it's a bit more complicated so unless you need it, skip it.

This post has been edited by Kakerergodt: 01 October 2012 - 09:09 PM

Was This Post Helpful? 1
  • +
  • -

#4 hanzechin  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 01-October 12

Re: Difficulties running the .jar files

Posted 01 October 2012 - 09:34 PM

View PostfromTheSprawl, on 01 October 2012 - 08:02 PM, said:

How do you run it? How do you export it? What's the error? I've successfully created a jar file of your program using Eclipse.


Well to be honest this is my first time attempting to export a java .jar file so i went through what I felt was obvious via Eclipse. File->Export->Java->Jar File and save that to desktop and attempt to run it and it says. Failed to load main class mainifest attribute from (where ever I've saved the .jar file)

View PostKakerergodt, on 01 October 2012 - 09:00 PM, said:

If you're gonna create a jar with a simple commandline use of javas jar.exe then drop the line with package in it, and it runs fine.

Edit: it's ofcourse possible to get it to run with the package line without the use of an IDE like NetBeans or Eclipse, but it's a bit more complicated so unless you need it, skip it.


Java's jar.exe file? would that be similar to droping it into a command prompt? My .java file that is? I'd prefer to learn the method of getting the package line to work via Eclipse or if it must be netbeans :P.
Was This Post Helpful? 0
  • +
  • -

#5 hanzechin  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 01-October 12

Re: Difficulties running the .jar files

Posted 01 October 2012 - 09:40 PM

Sorry for the double post coiuldn't find the edit button (it's not getting late a bit tired probably will go to sleep soon to look at the code with a fresher eye in the morning.) I've now looked up this video and has taken the liberty to follow this guy's way to export the Java file. http://www.youtube.c...h?v=RbhJ9sTMTD8 And realized here's the problem that's popping up for me.

Jar export finished with problems. See details for additional information.
Could not find main method from given launch configuration.
Was This Post Helpful? 0
  • +
  • -

#6 fromTheSprawl  Icon User is offline

  • Monomania
  • member icon

Reputation: 513
  • View blog
  • Posts: 2,055
  • Joined: 28-December 10

Re: Difficulties running the .jar files

Posted 01 October 2012 - 10:16 PM

1. Click Export
2. Click "Jar File" and Next.
3. "Export generated class files" and "Compress the contents" should be checked then click Next.
4. Select options for handling problems "Export" checkboxes should be checked(2 of them) then click Next.
5. Make sure "Generate the manifest file" is chosen but don't pick a checkbox. Choose "Seal the jar" then click "Browse" for the Main class textbox and choose NoodleWorksop.
6. Click "Finish", then try it.

I don't know why it's that way but that's what works for me. ^^
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1