Page 1 of 2 12 LastLast
Results 1 to 20 of 31
  1. #1
    oki
    oki is offline Member
    Join Date
    Aug 2011
    Posts
    20
    Rep Power
    0

    Default 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 ....

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,882
    Rep Power
    25

    Default

    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.

  3. #3
    oki
    oki is offline Member
    Join Date
    Aug 2011
    Posts
    20
    Rep Power
    0

    Default

    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.

  4. #4
    oki
    oki is offline Member
    Join Date
    Aug 2011
    Posts
    20
    Rep Power
    0

    Default

    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

  5. #5
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,882
    Rep Power
    25

    Default

    I get a no calss def error followed by an class not found exception.
    Please post the FULL text of the error message. You are leaving out important information from the message.
    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?

  6. #6
    oki
    oki is offline Member
    Join Date
    Aug 2011
    Posts
    20
    Rep Power
    0

    Default

    Java Applet starts then the applet field goes light blue-screenshot001.jpg

    This are my tries of running the applet from java command.
    The package is jChess.applet and class appletMain ( its the .java/.class and class name).
    What is wrong :( ?

  7. #7
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,882
    Rep Power
    25

    Default

    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

  8. #8
    oki
    oki is offline Member
    Join Date
    Aug 2011
    Posts
    20
    Rep Power
    0

    Default

    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

  9. #9
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,882
    Rep Power
    25

    Default

    C:\Users\Oki\Desktop\Deploy\test\jChess\applet>jav a appletMain
    Exception in thread "main" java.lang.NoClassDefFoundError: appletMain (wrong name: jChess/applet/appletMain)
    Try this:
    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.


    appletMain class which extends Applet
    There is some confusion.
    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?

  10. #10
    oki
    oki is offline Member
    Join Date
    Aug 2011
    Posts
    20
    Rep Power
    0

    Default

    Quote Originally Posted by Norm View Post
    Try this:
    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.
    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?

    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 :(

  11. #11
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,882
    Rep Power
    25

    Default

    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.

  12. #12
    oki
    oki is offline Member
    Join Date
    Aug 2011
    Posts
    20
    Rep Power
    0

    Default

    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).

  13. #13
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,882
    Rep Power
    25

    Default

    Are there any error messages in the browser's java console?
    Now we're back to where we were in post#2.

  14. #14
    oki
    oki is offline Member
    Join Date
    Aug 2011
    Posts
    20
    Rep Power
    0

    Default

    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 :/

  15. #15
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,882
    Rep Power
    25

    Default

    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 10:05 PM. Reason: Whoops, wrong window.

  16. #16
    oki
    oki is offline Member
    Join Date
    Aug 2011
    Posts
    20
    Rep Power
    0

    Default

    Yup it is in the track level 5.

    this is my function
    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();
        	
        }
    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 ?
    Last edited by Norm; 08-24-2011 at 10:21 PM. Reason: Added code tags

  17. #17
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,882
    Rep Power
    25

    Default

    What is the full text of the error message?

  18. #18
    oki
    oki is offline Member
    Join Date
    Aug 2011
    Posts
    20
    Rep Power
    0

    Default

    Well I showed you the Console .... I have a couple of

    Java Code:
    System.out.println(txt);
    and txt lets me check how far the code goes before i get

    "createGUI didn't complete successfully"
    Man - Everything works ok in the appletViewer.

    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

  19. #19
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,882
    Rep Power
    25

    Default

    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

  20. #20
    oki
    oki is offline Member
    Join Date
    Aug 2011
    Posts
    20
    Rep Power
    0

    Default

    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.

Page 1 of 2 12 LastLast

Similar Threads

  1. applet working in applet viewer, not browser
    By plasticfood in forum Java Applets
    Replies: 4
    Last Post: 06-24-2011, 07:47 PM
  2. Java Applet to Applet communication
    By jsman in forum Java Applets
    Replies: 3
    Last Post: 04-05-2011, 03:23 PM
  3. applet class inside java.applet.* or java.awt.*
    By Manish87 in forum Java Applets
    Replies: 1
    Last Post: 09-27-2010, 03:15 PM
  4. Calling another applet on click of button in one applet
    By niteshwar.bhardwaj in forum Java 2D
    Replies: 1
    Last Post: 02-19-2009, 01:54 PM
  5. Replies: 4
    Last Post: 06-08-2007, 07:15 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •