Have some technical trouble with compiling Java jar file with command line.
I have these two .java files in the same directory
// Source.java
package home;
public class Source {
public Source(){
System.out.println("This is the source.");
}
public static void main(String[] s){
System.out.println("this is England.");
System.out.println("ok 1 - Input file close");
new Source();
new Other();
System.exit(3);
}
}
// Other.java
package home;
public class Other {
public Other(){
System.out.println("More source here.");
}
}
I compile these two files into a .jar file like so:
#!/usr/bin/env bash
javac $(dirname "$0")/*.java
jar cmf MyJar.jar Manifest.txt *.class
the Manifest.txt file just contains these three lines:
Manifest-Version: 1.0
Created-By: <Your info>
Main-Class: home.Source
However when I try to execute the jar file with:
#!/usr/bin/env bash
java -jar MyJar.jar
I get this error:
Error: Could not find or load main class home.Source
I have no idea what to do now. Anybody know what's wrong? Perhaps I am using the wrong command to generate the .jar file?
As a check, I run jar tf
:
bash-3.2$ jar tf MyJar.jar
META-INF/
META-INF/MANIFEST.MF
Other.class
Source.class