Getting a jar file to work
Hi,
I am trying to get a jar file to work. My project is a little more complex than this, but, I was able to get the problem to work on a simpler project. Here it is:
[in home/FooIsFood/test directory]
Test.java:
// ==========================================
package test;
public class Test
{
public static void main(String[] args)
{
System.out.println(args[0]);
}
}
Now the manifest Test.mf:
Main-Class: Test
when I build the file like so, it works:
javac Test.java
and run it, this is what I get (as expected)
java Test Hello
Error: Could not find or load main class Test
but, if I change to the directory just below (ala cd ..)
and run:
java test/Test Hello
Hello
works as expected.
When I build the manifest:
(in test directory)
jar cvfm Test.jar Test.mf *.class
added manifest
adding: Test.class(in = 402) (out= 275)(deflated 31%)
I can't run the jar file from anywhere, from the test directory or home/FooIsFood any ideas?
Here's what I get in all cases:
Error: Could not find or load main class Test
Thanks!
|