Reputation: 105
So I've looked up many tutorials on how to compile code. I've tried to follow all of them. But I keep getting that error. Here's my code:
package ytho;
public class a {
public static void main(String[] args){
System.out.println("ytho");
}
}
And here's what I put for my manifest.txt:
Main-Class: a
I've also tried putting it as Main-Class: .a
and Main-Class: ytho.a
, to no avail.
I'm sorry that this is a duplicate, but all other tutorials on here haven't worked for me. So, I decided to finally ask myself. Help would be greatly appreciated. And if you need more information, let me know, but I may be late to reply.
Upvotes: 2
Views: 326
Reputation: 3751
Lets do it step my step:
a
class to A
since java uses Capitals on the first letter (this is stylistic)javac ytho/A.java
jar cvfm MyJarName.jar MANIFEST.MF *
Here is what my directory looks like
.
├── MANIFEST.MF
├── MyJarName.jar
└── ytho
├── A.class
└── A.java
Here is the content of the Manifest
Main-Class: ytho.A
And run it like so:
$: java -jar MyJarName.jar
which print out
ytho
Upvotes: 2
Reputation: 7868
In your manifest, you are missing the package in your classname:
Main-Class: ytho.a
See this link for more details: https://docs.oracle.com/javase/tutorial/deployment/jar/appman.html
Also, you should not name your class with all lowercase (or a single character for that matter).Call it something meaninful like JarTest.class or something
Upvotes: 0