java sdk1.3.1 help please..

hans007

Lifer
Feb 1, 2000
20,212
18
81
i made this program for school, and well it works find and all.


its called Puzzle.java


i type javac Puzzle.java
and it should just make

Puzzle.class but it makes


Puzzle$1.class through Puzzle$8.class and Puzzle.class

and it seems like it needs them all. this really sucks since my ftp wont let me upload files with a $ in them

can anyone help me fix it so its all in one file. I read it has to do with my using anonymous inner classes (i used 8 of them).

 

ugh

Platinum Member
Feb 6, 2000
2,563
0
0


<< Puzzle.class but it makes >>



Trying making a JAR out of all the class files by doing the following:

jar cvf Puzzle.jar *.class

This will create a Puzzle.jar file. To run the program, simply type:

java -jar Puzzle.jar
 

manly

Lifer
Jan 25, 2000
13,589
4,239
136


<<
java -jar Puzzle.jar
>>



Good advice, but the java -jar usage won't work unless he creates a manifest file that states what the Main-Class is.

hans007, the other .class files are for the inner classes.
 

AmigaMan

Diamond Member
Oct 12, 1999
3,644
1
0
you don't need the manifest file if you're only using the jar file to basically work like a zip file. I've used jar several times w/o having a manifest file.
 

ugh

Platinum Member
Feb 6, 2000
2,563
0
0


<< you don't need the manifest file if you're only using the jar file to basically work like a zip file. I've used jar several times w/o having a manifest file. >>


Actually, the jar command generates its own Manifest file. However, when I tried with JDK 1.3.1, I couldn't run the class I had jared inside. Had to add the line Main-Class: classname to the manifest file to get it to work.
 

hans007

Lifer
Feb 1, 2000
20,212
18
81
besides i need the .class file to be runnable off a webpage. i dont think it will be if i have a .jar file. its an applet not a program
 

ugh

Platinum Member
Feb 6, 2000
2,563
0
0


<< besides i need the .class file to be runnable off a webpage. i dont think it will be if i have a .jar file. its an applet not a program >>



Same procedure. JAR the class files, the add the following applet tag in yer HTML code:

<applet code=Puzzle.class archive=Puzzle.jar width=300 height=300></applet>