Results 1 to 10 of 10
  1. #1
    FakeRabbit is offline Member
    Join Date
    Sep 2008
    Posts
    9
    Rep Power
    0

    Default [SOLVED]starting a Swing application from an applet

    Hi,

    I wrote an application in netbeans using the Swing Application Framework and now I would like to write an applet with a button starting this application. The problem is, that when I run this applet I get the following error:
    Java Code:
    java.lang.NoClassDefFoundError: org/jdesktop/application/SingleFrameApplication
    here's the html file:
    Java Code:
    <APPLET codebase="classes" code="adminpanel/Admin.class" 
     width=50 height=200>
    </APPLET>
    ...and the applet code (the button is not yet here):
    Java Code:
    public class Admin extends JApplet{
        private JButton guzik;
    
        @Override
        public void init(){
            setLayout(new FlowLayout(FlowLayout.CENTER));
            
            AdminPanelApp.launch(AdminPanelApp.class, null);
            }}
    Last edited by FakeRabbit; 09-21-2008 at 07:01 PM.

  2. #2
    Nicholas Jordan's Avatar
    Nicholas Jordan is offline Senior Member
    Join Date
    Jun 2008
    Location
    Southwest
    Posts
    1,018
    Rep Power
    7

    Default

    type appletviewer: as the protocol

    put it in the browser address bar where http normally goes

    also, the slashes in the name path somehow are the same as the dots in filename, pathnames. Have not figured it out but it shows in the paths you are posting.
    Introduction to Programming Using Java.
    Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,589
    Rep Power
    23

    Default

    org/jdesktop/application/SingleFrameApplication
    The JVM can't find that class
    Where is the above reference class located? Probably in a jar file. Find that jar file, copy it to the folder with the HTML file and add archive=<jarfile> to the <APPLET tag

  4. #4
    FakeRabbit is offline Member
    Join Date
    Sep 2008
    Posts
    9
    Rep Power
    0

    Default

    Thanks for the reply.

    So I found the appframework-1.0.3.jar in dist/lib folder and copied it into the build folder, where my html is located. I edited the html file:
    Java Code:
    <APPLET codebase="classes" code="adminpanel/Admin.class" 
    ARCHIVE="appframework-1.0.3.jar"
    width=350 height=200></APPLET>
    Still the same error I'm afraid.

    type appletviewer: as the protocol

    put it in the browser address bar where http normally goes
    sorry, but I don't understand. What do I have to put in the addres bar and where do I type "appletviewer: as the protocol"?

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,589
    Rep Power
    23

    Default

    How are you loading the html into the browser? Directly by clicking on the html or via a server?
    Can you post the full contents of the error message in the Java Console?


    Whoops, just noticed the codebase= attribute. Try putting the jar file in that folder.
    Last edited by Norm; 09-18-2008 at 04:11 PM.

  6. #6
    FakeRabbit is offline Member
    Join Date
    Sep 2008
    Posts
    9
    Rep Power
    0

    Default

    Wow that seems to be the solution :) But now I'm experiencing another problem:
    Java Code:
    java.lang.NoClassDefFoundError: adminpanel/AdminPanelApp
    	at adminpanel.Admin.init(Admin.java:26)
    	at sun.applet.AppletPanel.run(Unknown Source)
    	at java.lang.Thread.run(Unknown Source)
    My first guess was to put the AdminPanel.jar file (jar with my application from dist folder) in the same folder as the rest of them but it didn't work out. I also tried to put it in classes/adminpanel folder - same result :(

    Oh and I am running it just by clicking on the html file.

  7. #7
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,589
    Rep Power
    23

    Default

    adminpanel/AdminPanelApp
    Is the above class file in the jar file with the correct path?
    Is the jar file in the ARCHIVE= attribute?
    The JVM won't look in a jar file for a class just because it's there. You must tell it to look at the jar file..

  8. #8
    FakeRabbit is offline Member
    Join Date
    Sep 2008
    Posts
    9
    Rep Power
    0

    Default

    okay, I've put the jar file in the adminpanel folder and changed AdminPanel.jar into adminpanel/AdminPanel.jar and the problem seems to be solved. Now I get another one:
    Java Code:
    javax.persistence.PersistenceException: No Persistence provider for EntityManager named fakerabbitPU: Provider named oracle.toplink.essentials.PersistenceProvider threw unexpected exception at create EntityManagerFactory: 
    java.security.AccessControlException
    java.security.AccessControlException: access denied (java.util.PropertyPermission toplink.logging.level read)
    Yeah, I know - it's just one after another error :) Thanks for your patience :)

  9. #9
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,589
    Rep Power
    23

    Default

    access denied (java.util.PropertyPermission toplink.logging.level read)
    Applets are NOT allowed to read files on the local PC. You need to giver permission to the applet to allow it to access local PC files.
    There have been posts on this forum with all the details. Use Search for Permission or .java.policy for them.

  10. #10
    FakeRabbit is offline Member
    Join Date
    Sep 2008
    Posts
    9
    Rep Power
    0

Similar Threads

  1. Application starting initially
    By rameshraj in forum Advanced Java
    Replies: 14
    Last Post: 04-27-2008, 07:48 PM
  2. EventHandling code for Swing application
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-07-2007, 12:06 PM
  3. swing application consumes much memory
    By oregon in forum AWT / Swing
    Replies: 1
    Last Post: 08-05-2007, 08:25 AM
  4. Create Windows, Applet & Swing
    By Eric in forum AWT / Swing
    Replies: 1
    Last Post: 07-05-2007, 06:36 AM
  5. Replies: 2
    Last Post: 07-04-2007, 06:58 AM

Posting Permissions

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