-
putting java class online
i created a game in applet and i want to put it on a site. the problem is that my games has alot of classes. how can i use applet tag to up it online?
java.php
Code :
<html>
...
<applet code = "Main.class" width = 900 height = 400> </applet>
...
</html>
my folder tree
Code :
-java_game
-java.php
-main.class
-item.class
-background.clas
-enemy.class
-...
-music
-...
-image
-...
-
Re: putting java class online
Quote:
my games has alot of classes
Put the classes into a jar file and add an archive= attribute to the <applet tag in the html
-
Re: putting java class online
i just have about 10 files inside my java project. not dont have package. do i have to make a package to create all thoses jar files??
-
Re: putting java class online
Quote:
do i have to make a package to create all thoses jar files??
No, you don't need to put the classes in packages.
-
Re: putting java class online
i am confuse
Quote:
Put the classes into a jar file and add an archive= attribute to the <applet tag in the html
i though i cant make applet into jar files?
-
Re: putting java class online
You can put any files into a jar file.
What is done with that jar file depends on what program is reading it.
-
1 Attachment(s)
Re: putting java class online
....so let me try again
here is my folder. it has all my java class and images and sounds.
Attachment 1904
in my java_game_2.php
i am using this tag. now if it was only one file than it works fine with this tag.
<applet code = "Main.class" width = 900 height = 400> </applet>
porblem is that i have more than one files. and when i run in web, it give me error i looked online but i could only file this example. can u plz help me to fix this problem?
error on web:
Quote:
Java Plug-in 1.6.0_29
Using JRE version 1.6.0_29-b11 Java HotSpot(TM) Client VM
User home directory = C:\Users\dave
----------------------------------------------------
c: clear console window
f: finalize objects on finalization queue
g: garbage collect
h: display this help message
l: dump classloader list
m: print memory usage
o: trigger logging
q: hide console
r: reload policy configuration
s: dump system and deployment properties
t: dump thread list
v: dump thread stack
x: clear classloader cache
0-5: set trace level to <n>
----------------------------------------------------
java.lang.UnsupportedClassVersionError: Main : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknow n Source)
at sun.plugin2.applet.Applet2ClassLoader.findClass(Un known Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(U nknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Un known Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Un known Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unk nown Source)
at sun.plugin2.applet.Plugin2Manager.createApplet(Unk nown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionR unnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception: java.lang.UnsupportedClassVersionError: Main : Unsupported major.minor version 51.0
-
Re: putting java class online
Put all the files used by the program into the jar file as said in post#2
Quote:
Unsupported major.minor version 51.0
That says the class file was created by a newer version of java (1.7) than the version of java being used to execute the code: Java Plug-in 1.6.0_29.
-
Re: putting java class online
i dont now how to put them in jar files. i was trying to put them in jar files in last post. but than u said something about Applets are not executed with the java command.
--- Update ---
so i need to download newversion of web java?
-
Re: putting java class online
The java command requires that the class it starts executing have a main() method.
Applets do not use a main() method.
Read the tutorial that I have given you several links to. It's explained there.
-
Re: putting java class online
i asked do i need to download new version of java?
i already now applet dont have main method.
-
Re: putting java class online
i asked do i need to download new version of java?
i already now applet dont have main method.
-
Re: putting java class online
The version of java that executes the class file must be compatible with the version of the JDK that created the class file. The new version of java JDK: 1.7 is NOT compatible with the older versions of java.
The javac command has options for creating class files that are compatible with older versions of java.
-
Re: putting java class online
just download new version of java. and errors are gone. but animation isnt moving and cant see my player. is this bc of not having jar file?
-
Re: putting java class online
Are there any error messages?
Locally executing a class from a jar file or from a disk file should not make any difference.
-
Re: putting java class online
-
Re: putting java class online
Try debugging the code by adding some println statements to print out messages showing execution flow and the values of variables as the code executes. The print out will help you see what the computer is doing when it executes your code.
-
Re: putting java class online
ah now its give me this error: any idea? i have the new version
Quote:
Java Plug-in 10.17.2.02
Using JRE version 1.7.0_17-b02 Java HotSpot(TM) Client VM
User home directory = C:\Users\dave
----------------------------------------------------
c: clear console window
f: finalize objects on finalization queue
g: garbage collect
h: display this help message
l: dump classloader list
m: print memory usage
o: trigger logging
q: hide console
r: reload policy configuration
s: dump system and deployment properties
t: dump thread list
v: dump thread stack
x: clear classloader cache
0-5: set trace level to <n>
----------------------------------------------------
Exception in thread "AWT-EventQueue-2" java.lang.NullPointerException
at Main.paint(Main.java:206)
at sun.awt.RepaintArea.paintComponent(Unknown Source)
at sun.awt.RepaintArea.paint(Unknown Source)
at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPri vilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPri vilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPri vilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilter s(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(U nknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarch y(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Exception in thread "AWT-EventQueue-3" java.lang.NullPointerException
at Main.paint(Main.java:206)
at sun.awt.RepaintArea.paintComponent(Unknown Source)
at sun.awt.RepaintArea.paint(Unknown Source)
at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPri vilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPri vilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPri vilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilter s(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(U nknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarch y(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Exception in thread "AWT-EventQueue-3" java.lang.NullPointerException
at Main.paint(Main.java:207)
at sun.awt.RepaintArea.paintComponent(Unknown Source)
at sun.awt.RepaintArea.paint(Unknown Source)
at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPri vilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPri vilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPri vilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilter s(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(U nknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarch y(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Main.java
line205: public void paint(Graphics g) {
line206: background_class.paint(g, this);
line207: ground_class.paint(g);
-
Re: putting java class online
Quote:
Exception in thread "AWT-EventQueue-2" java.lang.NullPointerException
at Main.paint(Main.java:206)
There is a variable with a null value when line 206 is executed. Look at line 206, find the variable with the null value and find out why it has a null value.
-
Re: putting java class online
i dont understand why in eclipse it have no error in Main.class but on web it gives me error.
great now new error:
Code :
Java Plug-in 10.17.2.02
Using JRE version 1.7.0_17-b02 Java HotSpot(TM) Client VM
User home directory = C:\Users\dave
----------------------------------------------------
c: clear console window
f: finalize objects on finalization queue
g: garbage collect
h: display this help message
l: dump classloader list
m: print memory usage
o: trigger logging
q: hide console
r: reload policy configuration
s: dump system and deployment properties
t: dump thread list
v: dump thread stack
x: clear classloader cache
0-5: set trace level to <n>
----------------------------------------------------
CacheEntry[http://localhost/E_COMMERCE/menu_pages/game_pages/java_game_2/Main.class]: updateAvailable=true,lastModified=Sat Nov 24 22:20:05 EST 2012,length=6998
CacheEntry[http://localhost/E_COMMERCE/menu_pages/game_pages/java_game_2/Enemy.class]: updateAvailable=true,lastModified=Sat Nov 10 10:28:15 EST 2012,length=2340
CacheEntry[http://localhost/E_COMMERCE/menu_pages/game_pages/java_game_2/Enemy_1.class]: updateAvailable=true,lastModified=Sat Nov 10 10:28:48 EST 2012,length=1834
CacheEntry[http://localhost/E_COMMERCE/menu_pages/game_pages/java_game_2/Platform.class]: updateAvailable=true,lastModified=Sat Nov 10 10:26:29 EST 2012,length=2535
CacheEntry[http://localhost/E_COMMERCE/menu_pages/game_pages/java_game_2/Item.class]: updateAvailable=true,lastModified=Sat Nov 10 10:26:41 EST 2012,length=1757
CacheEntry[http://localhost/E_COMMERCE/menu_pages/game_pages/java_game_2/Sprite_Sheet.class]: updateAvailable=true,lastModified=Sat Nov 10 07:29:27 EST 2012,length=1603
CacheEntry[http://localhost/E_COMMERCE/menu_pages/game_pages/java_game_2/Background.class]: updateAvailable=true,lastModified=Sat Nov 10 10:30:05 EST 2012,length=1535
Exception in thread "AWT-EventQueue-2" java.lang.NullPointerException
at Main.paint(Main.java:204)
at sun.awt.RepaintArea.paintComponent(Unknown Source)
at sun.awt.RepaintArea.paint(Unknown Source)
at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
CacheEntry[http://localhost/E_COMMERCE/menu_pages/game_pages/java_game_2/Ground.class]: updateAvailable=true,lastModified=Sat Nov 10 10:28:04 EST 2012,length=2312
Code :
/*** paint method ***/
@Override
public void paint(Graphics g)
{
background_class.paint(g, this); //line204
ground_class.paint(g); //line205
//line 206
player_class.paint(g);
for(int i = 0; i < platform_class.length; i++)
{ platform_class[i].paint(g); }
shoot_class.paint(g, player_class); //draw bullet
enemy_class.paint(g, enemy_class);
for(int i = 0; i < item_class.length; i++)
{ item_class[i].paint(g); }
score_class.paint(g, this, player_class);
}/*** end of paint method ***/
the line look fine to me.
-
Re: putting java class online
What variable has the null value? If you don't know, add a println() statement to print out the values of all the variables.
Where is that variable assigned a value?
-
Re: putting java class online
on line 204: i printed the value of 'this'
Quote:
Main[panel0,0,0,900x400,layout=java.awt.FlowLayout]
on line 204: i printed the value of 'g'
Quote:
sun.java2d.SunGraphics2D[font=java.awt.Font[family=Serif,name=Serif,style=bold,size=20],color=java.awt.Color[r=15,g=77,b=147]]
on line 204: i printed the value of 'background_class'
Quote:
Background@31908ba7
they all have some values
-
Re: putting java class online
Did the program get the exception immediately after those println()s were executed?
Keep adding println() statements to show the variables used on each line until you see the variable that is null.
-
Re: putting java class online
yes and printed the value right after the line 204
-
Re: putting java class online
Did the program get the exception immediately after those println()s were executed?
Keep adding println() statements to show the variables used on each line until you see the variable that is null.
Copy and post the whole contents showing the print outs and the exception error message