Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Class files question

Status
Not open for further replies.

bos

Technical User
Oct 1, 2002
50
US
I'm new to programming in Java and I noticed a lot of class files being created as I program. Is there a way to archive or compress the class files and still be able to run the program I've written?

Thanks in advance.
 
You could place all of the class files into a jar and run them from there. The classes in the jar may be compressed or uncompressed, it is your choice.
 
<sarcasm>
Yes, really. I also prefer to keep my jars on the top shelf because I think they perform better due to the higher altitude.
</sarcasm>
On another note, I feel sarcasm should official be supported in html as a markup tag. It would lead to less confusion in places like this.
 
I tried placing them into a .jar before. I placed all the class files in their own directory and made them into a .jar file. However when I tried to run the program it didn't work right. Was there something I did wrong?
 
I created a .jar file out of all of my class files. I then created a text file to try and set up my Main-Class attribute:

Main-Class: Program

I then tried running the program and recieved the following error:

Exception in thread &quot;main&quot; java.lang.NoClassDefFoundError: Program

Could you please let me know what the problem might be. And thanks for the site listed above. It was very helpful.
 
The Manifest with the Main-Class attribute has to be IN the Jar in the META-INF directory in the file called MANIFEST.MF.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top