Hi,
I have a really simple program that I put into a jar file. I followed the tutorials and managed to get
it to work, but only while the jar is in the same folder as all the files that went into it. When I move
the jar to my desktop and try to execute; it wont open. I gotta be doing something wrong here,
any help, tips or abuse is greatly appreciated. Oh by the way, I'm using a Mac Book Pro.
Thanks
Here is the command I used to build the jar:
Here is what is in the jar
Here is my manifest:
Here is my src:
I have a really simple program that I put into a jar file. I followed the tutorials and managed to get
it to work, but only while the jar is in the same folder as all the files that went into it. When I move
the jar to my desktop and try to execute; it wont open. I gotta be doing something wrong here,
any help, tips or abuse is greatly appreciated. Oh by the way, I'm using a Mac Book Pro.
Thanks
Here is the command I used to build the jar:
Code:
billMBP:~/desktop/lab6_Find1 bill$ jar cvfm Find1.jar myManifest.txt Find1.class invoice.dat Q_icon.jpg W_icon.jpg
added manifest
adding: Find1.class(in = 2633) (out= 1612)(deflated 38%)
adding: invoice.dat(in = 35) (out= 35)(deflated 0%)
adding: Q_icon.jpg(in = 17902) (out= 17020)(deflated 4%)
adding: W_icon.jpg(in = 6758) (out= 6749)(deflated 0%)
Here is what is in the jar
Code:
billMBP:~/desktop/lab6_Find1 bill$ jar xvf Find1.jar
created: META-INF/
inflated: META-INF/MANIFEST.MF
inflated: Find1.class
inflated: invoice.dat
inflated: Q_icon.jpg
inflated: W_icon.jpg
Here is my manifest:
Code:
Manifest-Version: 1.0
Main-Class: Find1
Created-By: 1.5 (Sun Microsystems Inc.)
Here is my src:
Code:
import java.io.*;
import java.util.*;
import java.text.DecimalFormat;
import javax.swing.*;
public class Find1 {
public static void main(String[] args) throws FileNotFoundException {
DecimalFormat dF = new DecimalFormat("0.00");
Scanner fr = new Scanner(new FileReader("invoice.dat"));
double itemPrice = 0;
String itemFromStock = null;
String usrIn = null;
boolean found = false;
Icon Q = new ImageIcon("Q_icon.jpg");
JLabel Qjl = new JLabel("Please enter the name of the item you "
+ "want information about...", Q, JLabel.CENTER);
usrIn = JOptionPane.showInputDialog(null, Qjl, "SUPER INVENTORY "
+ "SEARCH FACILITATOR ©2006", JOptionPane.PLAIN_MESSAGE);
while (!found && fr.hasNext()) {
itemFromStock = fr.nextLine();
if (usrIn.equalsIgnoreCase(itemFromStock)) {
found = true;
itemPrice = fr.nextDouble();
JOptionPane.showMessageDialog(null, "The "
+ itemFromStock
+ " is available for: $"
+ dF.format(itemPrice), "Your Inquiry Results",
JOptionPane.INFORMATION_MESSAGE);
}
}
if (!found) {
Icon W = new ImageIcon("W_icon.jpg");
JLabel Wjl = new JLabel(
"<html>\"<strong>Sorry !!</strong> but, we don't carry "
+ "<strong>"
+ usrIn
+ "s</strong> anymore. We had a <p>bunch of 'um a "
+ "while back and they just sat on the shelves</p> "
+ "till the mice got to 'um and well... I don't "
+ "have to tell <em><strong>you</strong></em>"
+ " how much of a hassle.... blah blah blah..."
+ "blah..\"</html>", W, JLabel.CENTER);
JOptionPane.showMessageDialog(null, Wjl, "Sorry for Your Trouble",
JOptionPane.ERROR_MESSAGE);
}
fr.close();
System.exit(0);
}
}