Results 1 to 20 of 31
- 08-22-2011, 10:26 PM #1
Member
- Join Date
- Aug 2011
- Posts
- 20
- Rep Power
- 0
Java Applet starts then the applet field goes light blue
Hi, i've implemented a chess game in java in Eclipse IDE. It works great in the applet viewer, but it fails to run when deploying it on a webpage like this
<applet code=jChess.applet.appletMain.class
archive="test.jar"
width=800 height=800>
</applet>
I export the file as JAR and check to export generated class and resources, export java sorce files and resources and add directory entries. I check the .classpath and .project also all source files and images. What can be the source of this failure ? How to deploy the project properly ? Guys help cuz im tearing my hair ....
- 08-23-2011, 02:33 AM #2
Is there an error message in the browser's java console?
Have you looked inside of the jar file to be sure the files are in the correct folders? You can use a zip utility to open and examine a jar file.
- 08-23-2011, 06:10 AM #3
Member
- Join Date
- Aug 2011
- Posts
- 20
- Rep Power
- 0
There was an error message that the class could not be found i dealt with it and now everything seems to load but it gets "stuck" on a light blue screen which to say is not part of my applet. Ill check the jar with the zip and notice you when il get back from work.
- 08-23-2011, 03:53 PM #4
Member
- Join Date
- Aug 2011
- Posts
- 20
- Rep Power
- 0
OK, the jar contains everything ( source *.png s, source java, and .class files)
The .classpath contains :
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry exported="true" kind="lib" path="C:/Users/Oki/Downloads/mysql-connector-java-5.1.17/mysql-connector-java-5.1.17/mysql-connector-java-5.1.17-bin.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>
when i try to run the main applet class from cmd " java mainClass.class
I get a no calss def error followed by an class not found exception.
Plz help me out guys
- 08-23-2011, 04:13 PM #5
Please post the FULL text of the error message. You are leaving out important information from the message.I get a no calss def error followed by an class not found exception.
What is the name of your class? The java command uses the classname NOT the filename.
I thought the program was an applet that runs in a browser. Why are you using the command prompt?
- 08-23-2011, 09:17 PM #6
Member
- Join Date
- Aug 2011
- Posts
- 20
- Rep Power
- 0
- 08-23-2011, 09:24 PM #7
Is your code an applet or an application? Applets extend the Applet class.
Please copy and paste the contents of the command prompt console here. I can't copy and paste from an image to make suggestions on what the java command should look like.
To copy the contents of the command prompt window:
Click on Icon in upper left corner
Select Edit
Select 'Select All' - The selection will show
Click in upper left again
Select Edit and click 'Copy'
Paste here.
If you are using packages, you must be in the folder that contains the head of the package path, the class file must be in the end of package path folder and you must use the full package on the java command.
The java command uses the class name NOT the filename. IE no ending .class
- 08-23-2011, 10:26 PM #8
Member
- Join Date
- Aug 2011
- Posts
- 20
- Rep Power
- 0
C:\Users\Oki\Desktop\Deploy\test\jChess\applet>jav a appletMain
Exception in thread "main" java.lang.NoClassDefFoundError: appletMain (wrong nam
e: jChess/applet/appletMain)
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 java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: appletMain. Program will exit.
C:\Users\Oki\Desktop\Deploy\test\jChess\applet>jav a jChess.applet.appletMain
Exception in thread "main" java.lang.NoClassDefFoundError: jChess/applet/appletM
ain
Caused by: java.lang.ClassNotFoundException: jChess.applet.appletMain
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: jChess.applet.appletMain. Program will exit.
C:\Users\Oki\Desktop\Deploy\test\jChess\applet>jav a appletMain.class
Exception in thread "main" java.lang.NoClassDefFoundError: appletMain/class
Caused by: java.lang.ClassNotFoundException: appletMain.class
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: appletMain.class. Program will exit.
C:\Users\Oki\Desktop\Deploy\test\jChess\applet>jav a appletMain
Exception in thread "main" java.lang.NoClassDefFoundError: appletMain (wrong nam
e: jChess/applet/appletMain)
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 java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: appletMain. Program will exit.
C:\Users\Oki\Desktop\Deploy\test\jChess\applet>cd. .
C:\Users\Oki\Desktop\Deploy\test\jChess>cd..
C:\Users\Oki\Desktop\Deploy\test>java appletMain
Exception in thread "main" java.lang.NoClassDefFoundError: appletMain
Caused by: java.lang.ClassNotFoundException: appletMain
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: appletMain. Program will exit.
C:\Users\Oki\Desktop\Deploy\test>java jChess\applet\appletMain
Exception in thread "main" java.lang.NoClassDefFoundError: jChess\applet\appletM
ain (wrong name: jChess/applet/appletMain)
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 java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: jChess\applet\appletMain. Program will exit.
C:\Users\Oki\Desktop\Deploy\test>
I used packages (jar) but now i unzipped it and tried to run the appletMain class which extends Applet and implements ActionListener.
As I mentioned it works great in eclipse (run applet) and in the configuration there is a path to the main class jChess.applet.appletMain. I pased my tries of calling the class from the cmd.Hope you can help
- 08-23-2011, 10:32 PM #9
Try this:C:\Users\Oki\Desktop\Deploy\test\jChess\applet>jav a appletMain
Exception in thread "main" java.lang.NoClassDefFoundError: appletMain (wrong name: jChess/applet/appletMain)
Go to the folder that contains the jChess folder: test (the folder containing jChess) and enter:
java jChess.applet.appletMain
I assume the appletMain.class file is in the applet folder.
There is some confusion.appletMain class which extends Applet
Does the appletMain class contain a public static void main(String[] args) method?
Is your code supposed to be executed in a browser or from the command line?
- 08-24-2011, 03:49 PM #10
Member
- Join Date
- Aug 2011
- Posts
- 20
- Rep Power
- 0
C:\Users\Oki\Desktop\Deploy\test>java jChess.applet.appletMain
Exception in thread "main" java.lang.NoSuchMethodError: main
C:\Users\Oki\Desktop\Deploy\test>
It has no "public static main ..." function, it is meant for opening in a web browser. It has an Init function It Runs great in the Eclipse AppletViewer ( in its configuration the main class pointed as the starting class is jChess.applet.appletmain. I tried a simpler applet and it worked. This seems to not work I have a jar dependency - only that file is not included - but i dont use it in my applet right now ( no import on it in the appletMain class or other classes). Help Me out :(
- 08-24-2011, 03:54 PM #11
Your first post shows html with the applet tag. What happens when you use that?
Remember to put the class files in folders that agree with the package they are in.
I never understood why you tried to execute the applet code with the java command. It won't work.
- 08-24-2011, 05:19 PM #12
Member
- Join Date
- Aug 2011
- Posts
- 20
- Rep Power
- 0
I already said the web page opens the cursor goes to "waiting" then nothing happens. Its white. Now i Noticed that if you og to a different page and go back to the applet page The screen will stay on the piece of the webpage that the applet is ( and earlier went white).
- 08-24-2011, 05:28 PM #13
Are there any error messages in the browser's java console?
Now we're back to where we were in post#2.
- 08-24-2011, 09:01 PM #14
Member
- Join Date
- Aug 2011
- Posts
- 20
- Rep Power
- 0
now we are "getting"somewhere :D i enabled the console it prints "createGUI didn't complete successfully" but can i get more detail ?
And in detail:
Trace level set to 5: all ... completed.
basic: Starting applet teardown
basic: Finished applet teardown
basic: Added progress listener: sun.plugin.util.GrayBoxPainter$GrayBoxProgressList ener@fd68b1
basic: Plugin2ClassLoader.addURL parent called for file:/C:/Users/Oki/Desktop/Deploy/test.jar
basic: Applet loaded.
basic: Applet resized and added to parent container
basic: PERF: AppletExecutionRunnable - applet.init() BEGIN ; jvmLaunch dt 275134 us, pluginInit dt 152946912 us, TotalTime: 153222046 us
createGUI didn't complete successfully
basic: Applet initialized
basic: Removed progress listener: sun.plugin.util.GrayBoxPainter$GrayBoxProgressList ener@fd68b1
basic: Applet made visible
basic: Starting applet
basic: completed perf rollup
basic: Applet started
basic: Told clients applet is started
createGUI is my fuinction inside the init of the applet ... but what went wrong :/ everything is ok in eclipse I even tried to disable the chess pictures that are image icons and it did not work :/
- 08-24-2011, 09:04 PM #15
Sorry, I'm not familiar with the output you posted.
Is your post from the java console window?Last edited by Norm; 08-24-2011 at 09:05 PM. Reason: Whoops, wrong window.
- 08-24-2011, 09:17 PM #16
Member
- Join Date
- Aug 2011
- Posts
- 20
- Rep Power
- 0
Yup it is in the track level 5.
this is my function
AFAIK layerdPane.add(chessBoard,JLayeredPane.DEFAULT_LAY ER); this produces an error and then some other commands which i didnt check but I managed to find out that this provieds an error ... Any idea why ?Java Code:private void createGUI() { System.out.println("Creating GUI"); view=pieceColor.white; Dimension d=new Dimension(620,620); System.out.println("Seting DIM"); this.setSize(d); this.setMinimumSize(d); this.setPreferredSize(d); System.out.println("After setting DIM"); layerdPane= new JLayeredPane(); System.out.println("After PANE"); //this.add(new Board(80,80)); chessBoard = new Board(600,600); System.out.println("After BOARD"); layerdPane.add(chessBoard,JLayeredPane.DEFAULT_LAYER); System.out.println("After ADD PANE"); // bLayout.addLayoutComponent(layerdPane,BorderLayout.CENTER); this.setBounds(0, 0, 620, 620); GridBagConstraints c = new GridBagConstraints(); this.getContentPane().setLayout(new BorderLayout()); JPanel boardPanel=new JPanel(); boardPanel.setLayout(new GridBagLayout()); c.gridx=0; c.gridy=0; boardPanel.add(createChessBorderXWhite(false),c); c.gridx=1; c.gridy=0; c.fill=GridBagConstraints.BOTH; layerdPane.setVisible(true); boardPanel.add(layerdPane,c); c.fill=GridBagConstraints.NONE; c.gridx=1; c.gridy=1; boardPanel.add(createChessBorderXWhite(true),c); this.getContentPane().add(boardPanel,BorderLayout.CENTER); addButtons(); this.repaint(); }Last edited by Norm; 08-24-2011 at 09:21 PM. Reason: Added code tags
- 08-24-2011, 09:20 PM #17
What is the full text of the error message?
- 08-24-2011, 09:39 PM #18
Member
- Join Date
- Aug 2011
- Posts
- 20
- Rep Power
- 0
Well I showed you the Console .... I have a couple of
and txt lets me check how far the code goes before i getJava Code:System.out.println(txt);
Man - Everything works ok in the appletViewer."createGUI didn't complete successfully"
The output without changing the console track level
Java Code:Java Plug-in 1.6.0_26 Using JRE version 1.6.0_26-b03 Java HotSpot(TM) Client VM User home directory = C:\Users\Oki ---------------------------------------------------- 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> ---------------------------------------------------- Creating GUI Seting DIM After setting DIM After PANE createGUI didn't complete successfully
- 08-24-2011, 09:42 PM #19
Do you have any catch blocks that do NOT call printStackTrace? If so, go back and add calls to that method so you can see what the real error message is. This simple message could be hiding the real problem:
createGUI didn't complete successfully
- 08-24-2011, 09:49 PM #20
Member
- Join Date
- Aug 2011
- Posts
- 20
- Rep Power
- 0
Yeah id does... imanaged to find out that the chessBoard is creating the problem ( i had it in a comment earlier so i thought that adding it gave a problem and it did beacuse it wass null but the real problem is the creation of the board - i started commenting code to check the error).
I think that there is sommething bad with my loading of the ICONS .... i have to get them in another way. Now i get them as getIcon andi t should be ressoursce stream ... or somewhat.
Similar Threads
-
applet working in applet viewer, not browser
By plasticfood in forum Java AppletsReplies: 4Last Post: 06-24-2011, 06:47 PM -
Java Applet to Applet communication
By jsman in forum Java AppletsReplies: 3Last Post: 04-05-2011, 02:23 PM -
applet class inside java.applet.* or java.awt.*
By Manish87 in forum Java AppletsReplies: 1Last Post: 09-27-2010, 02:15 PM -
Calling another applet on click of button in one applet
By niteshwar.bhardwaj in forum Java 2DReplies: 1Last Post: 02-19-2009, 12:54 PM -
Applet, To center text and To open I engage in a dialog in an Applet
By Marcus in forum Java AppletsReplies: 4Last Post: 06-08-2007, 06:15 AM


LinkBack URL
About LinkBacks
Reply With Quote


Bookmarks