"Should array indices start at 0 or 1? My compromise of 0.5 was rejected without, I thought, proper consideration."- Stan Kelly-Bootle
You down with OOP? Yeah you know me!
You down with OOP? Yeah you know me!
public class Hi
{
public static void main(String[] args)
{
System.out.println("Hi!");
}
}
A:\Java>dir
Volume in drive A has no label.
Volume Serial Number is 0000-0000
Directory of A:\Java
02/26/2007 04:27 PM <DIR> .
02/26/2007 04:27 PM <DIR> ..
02/26/2007 04:42 PM 105 Hi.java
02/26/2007 04:42 PM 501 Hi.class
02/26/2007 04:33 PM 24 manifest.txt
3 File<s> 630 bytes
2 Dir<s> 219,648 bytes free
A:\Java>jar cvmf manifest.txt hi.jar hi.class
added manifest
adding: hi.class<in = 501> <out = 317><deflated 36%>
A:\Java>hi.jar
A:\Java> (it is right after this appeared that the Java Virtual Machine error above appeared it a Windows message box)
A:\Java>edlin A:\Java\manifest.txt
End of input file
*L
1:*Main-Class: Hi
2:
3:
4:
5:
//I think this is how it should display, unless the asterisk in line 1 shouldn't be there.
*q
Abort edit?y
A:\Java>
Thomas Kiersted wrote:Hello everyone. I'm trying to make an executable .jar file, but cannot seem to figure out the manifest. I've Googled, checked java.sun.com, and checked recent topics here, but haven't figured it out yet. I'll start with all the information about the files:
*I have HelloWorld.class, HelloWorld.java, and HelloWorld.ctxt all in A:\Hello . The class runs fine in the editor I'm using, BlueJ. HelloWorld.class just prints "Hello World" within the public static void main(String[]args).
I'm trying to create the .jar file using MS-DOS and would like to succeed at that before trying Eclipse or another program. I have added the necessary files to the System Path, and overcome that obstacle. Here is what I am trying in MS-DOS:
1. Change directory to A:\Hello
2. Create manifest file by typing 'echo Main-Class: HelloWorld >manifest.txt'
3. Create .jar file by typing 'jar cvmf manifest.txt HelloWorld.jar HelloWorld.class'
I then try to run the .jar. When I type HelloWorld.jar in the command prompt or double-click the .jar from Windows Explorer, I get the error 'Could not find the main class. Program will exit.' When I type java -jar HelloWorld.jar I get the error 'Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld'. I'm lost as to what to do, but I think it's with the manifest file. I've tried the following modification:
1. Adding 'ClassPath: .\Hello.jar' at the beginning of the manifest file using notepad. I don't think this is necessary, as the manifest file is in the same directory as the class file, but I'm not sure. However, when I create the Manifest file using notepad, I get the error 'java.io.IOException: invalid header name: (unusual characters)Main-Class at...'.
To summarize, the main problem is that I cannot figure out the error 'Could not find the main class. Program will exit.' I think this is being caused by an error I am making in the manifest file; my second guess is it has something to do with how I have the files set up in the directories.
Thanks alot. This has me bamboozled.
Thomas Kiersted
Consider Paul's rocket mass heater. |