• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Start: Applet not initialized

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Radhika Srinivasan
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nothing looks wrong in your code, there might be something wrong in the applet tag you are using.
 
Sheriff
Posts: 22821
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check the Java console, in your system tray.
 
Radhika Srinivasan
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
----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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
None of the problems execute in command line .......... That's the reason I use JGRASP to execute programs......

Thanks,
Radhika
 
Rob Spoor
Sheriff
Posts: 22821
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Even after changing the tag I receive the same error.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 22821
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 22821
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well the applet thingy is causing the "java.security.AccessControlException: access denied (java.lang.RuntimePermission modifyThreadGroup)" exception.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
What are you doing in my house? Get 'em tiny ad!
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic