aspose file tools*
The moose likes Beginning Java and the fly likes Start: Applet not initialized Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Start: Applet not initialized" Watch "Start: Applet not initialized" New topic
Author

Start: Applet not initialized

Radhika Srinivasan
Ranch Hand

Joined: Jul 28, 2009
Posts: 32
Write an applet that implements the runnable interface that will simulate a yo-yo going up & down on a string. To reduce flickers, repaint only the string and YO-YO in the back ground color.

Kindly help me sort out the error.

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42267
    
  64
Sounds like homework you're supposed to be doing in order to learn something. What do you have so far, and where are you stuck making progress?


Ping & DNS - my free Android networking tools app
Radhika Srinivasan
Ranch Hand

Joined: Jul 28, 2009
Posts: 32
Yes your right this is my course work but i'm stuck with it ...,.. would you help me in getting of the error......... or help me sort out where exactly things have gone wrong .............

Many thanks,
Radhika
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1477
    
    6

Nothing looks wrong in your code, there might be something wrong in the applet tag you are using.


Swastik
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19718
    
  20

Check the Java console, in your system tray.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Radhika Srinivasan
Ranch Hand

Joined: Jul 28, 2009
Posts: 32
----jGRASP exec: java YoYo

java.lang.NoSuchMethodError: main
Exception in thread "main"
----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.

----jGRASP exec: appletviewer jgrasphta.htm

java.security.AccessControlException: access denied (java.lang.RuntimePermission modifyThreadGroup)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:323)
at java.security.AccessController.checkPermission(AccessController.java:546)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at sun.applet.AppletSecurity.checkAccess(AppletSecurity.java:235)
at java.lang.ThreadGroup.checkAccess(ThreadGroup.java:288)
at java.lang.Thread.init(Thread.java:332)
at java.lang.Thread.<init>(Thread.java:391)
at YoYo.init(YoYo.java:21)
at sun.applet.AppletPanel.run(AppletPanel.java:424)
at java.lang.Thread.run(Thread.java:619)

----jGRASP: operation complete.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42267
    
  64
Works fine for me both in appletviewer and in a browser.

What is this jGRASP thing - some kind of execution environment? Maybe it applies additional security restrictions - try running the "appletviewer jgrasphta.htm" command on the command line.
Radhika Srinivasan
Ranch Hand

Joined: Jul 28, 2009
Posts: 32
None of the problems execute in command line .......... That's the reason I use JGRASP to execute programs......

Thanks,
Radhika
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19718
    
  20

Applets run in a "sandbox", with very little permissions to access anything other than the website the applet is downloaded from.
Radhika Srinivasan
Ranch Hand

Joined: Jul 28, 2009
Posts: 32
When I try executing in command line I receive the following :

Microsoft Windows [Version 6.0.6001]
Copyright (c) 2006 Microsoft Corporation. All rights reserved.

C:\Users\Radhika>cd C:\Java Working Directory

C:\Java Working Directory>javac YoYo.java

C:\Java Working Directory>java YoYo
Exception in thread "main" java.lang.NoClassDefFoundError: YoYo
Caused by: java.lang.ClassNotFoundException: YoYo
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)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: YoYo. Program will exit.

C:\Java Working Directory>
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42267
    
  64
The YoYo class is an applet - it does not have a "main" method that would allow it to be executed on the command line.

For applets you'll have to create an HTML that contains an applet tag, and then you can use a browser to open the HTML file (which will cause the applet to be run). It's sufficient to put something like this in the HTML file:
Radhika Srinivasan
Ranch Hand

Joined: Jul 28, 2009
Posts: 32
Even after changing the tag I receive the same error.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42267
    
  64
You can't possibly get that error if you run the code as an applet; you can only get it if you try to run it as an application. What, exactly, are you typing in at the command line?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19718
    
  20

Rob Prime wrote:Applets run in a "sandbox", with very little permissions to access anything other than the website the applet is downloaded from.

I quote myself just because it's so important. Besides I/O restrictions, you also can't change much threading properties.

Also read http://faq.javaranch.com/java/AppletsFaq
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42267
    
  64
I don't think that's the real issue here. Applets are allowed start and manage threads on their own w/o special permissions. It's just a different threadgroup in this case because of the jGRASP thingie. In an actual applet environment (appletviewer or browser) that wouldn't be an issue (I think).
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19718
    
  20

Well the applet thingy is causing the "java.security.AccessControlException: access denied (java.lang.RuntimePermission modifyThreadGroup)" exception.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42267
    
  64
If you look at the code, all the applet does with threads is to create its own thread - which applets are allowed to do. I'm betting that the exception occurs only within this special environment, which apparently does not properly emulate a normal applet environment.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Start: Applet not initialized