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.
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 .............
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: 35443
9
posted
0
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
Greenhorn
Joined: Jul 28, 2009
Posts: 29
posted
0
None of the problems execute in command line .......... That's the reason I use JGRASP to execute programs......
Applets run in a "sandbox", with very little permissions to access anything other than the website the applet is downloaded from.
Radhika Srinivasan
Greenhorn
Joined: Jul 28, 2009
Posts: 29
posted
0
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: 35443
9
posted
0
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
Greenhorn
Joined: Jul 28, 2009
Posts: 29
posted
0
Even after changing the tag I receive the same error.
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35443
9
posted
0
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?
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).
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: 35443
9
posted
0
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.