Results 1 to 8 of 8
Thread: ClassNotFoundException
- 05-12-2010, 04:26 AM #1
Member
- Join Date
- May 2010
- Posts
- 23
- Rep Power
- 0
ClassNotFoundException
I was trying to embed my applet to a simple page.
My Test.class file is in the same directory as my html file. But when I run the html file, i got a bunch of errors:XML Code:<html> <body> <applet code="Test.class" width="700" height="750"> </applet> </body> </html>
Could anyone please tell me how to fix this?Java Code:Exception: java.lang.ClassNotFoundException: Test.class load: class Test.class not found. java.lang.ClassNotFoundException: Test.class at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source) at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source) at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: java.io.FileNotFoundException: \\localhost\classes\Test\class.class (The network name cannot be found) at java.io.FileInputStream.open(Native Method) at java.io.FileInputStream.<init>(Unknown Source) at java.io.FileInputStream.<init>(Unknown Source) at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source) at sun.net.www.protocol.file.FileURLConnection.getInputStream(Unknown Source) at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source) at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source) at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) ... 7 more Exception: java.lang.ClassNotFoundException: Test.class
Thanks.
P.S: I'm new, VERY new to applet. Today's the first lesson of mine on Applet at school~!
- 05-12-2010, 12:07 PM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Isn't it simply "Test"?
I think "Test.class" will have it looking for the "class" Class in the "Test" package.
- 05-12-2010, 06:51 PM #3
Senior Member
- Join Date
- Jul 2008
- Posts
- 125
- Rep Power
- 0
You've probably already found the answer by now,
but here it is again:
Java Code:<html> <body> <applet code="Test.java" width="700" height="750"> </applet> </body> </html>
- 05-13-2010, 06:07 AM #4
Member
- Join Date
- May 2010
- Posts
- 23
- Rep Power
- 0
Are you sure it's the ".java" file that I must put in the code = '...' part?
- 05-13-2010, 08:57 AM #5
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
This error:
java.io.FileNotFoundException: \\localhost\classes\Test\class.class (The network name cannot be found)
is your problem.
Have you tried without the .class? It's not the way it's supposed to be done, but that error implies it's the problem I mentioned above.
- 05-13-2010, 04:28 PM #6
Following Tolls post:
Java thought that Test.class was a package path. Ie that Test was a folder and class was the name of the .class file in the Test folder.
Removing the .class should fix it.
- 05-13-2010, 10:51 PM #7
Senior Member
- Join Date
- Jul 2008
- Posts
- 125
- Rep Power
- 0
Here is how I know
<applet code="Test.java" width="700" height="750">
works.
When I read this thread, I went to one of my
folders of java projects that use very brief html
code to run those projects.
I found code that is practically exact to the
html code you wrote, except for dimensions
and the <applet.. > line. Simply stated, I
know empirically that
<applet code="Test.java" width="700" height="750">
works from the working examples in my folder.
(note: you must have your Test.class code in that
directory/folder to make it work, and you do not
need the Test.java source code in there at all.)
Why
code = "Test.java"
but not
code = "Test.class"?
I think it's because html can work with other languages.
You could have Visual Basic code to run,
therefore that html line would be:
<applet code="Test.vbasic" width="700" height="750">
or whatever extension they use to inform the html
interpreter/compiler that Visual Basic is embedded
within it. Still, the compiled code (Test.class) must
exist in that directory order to be executed.Last edited by paul pasciak; 05-13-2010 at 11:02 PM. Reason: closed parenthesis
- 05-13-2010, 11:09 PM #8
Similar Threads
-
ClassNotFoundException
By lgpublic in forum Advanced JavaReplies: 5Last Post: 04-23-2010, 03:05 PM -
ClassNotFoundException
By Edward in forum New To JavaReplies: 2Last Post: 06-29-2009, 07:08 PM -
ClassNotFoundException JSP
By TDMaster in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 03-27-2009, 07:41 AM -
ClassNotFoundException
By Chezelle in forum Java AppletsReplies: 5Last Post: 12-24-2008, 04:26 PM -
Getting UnmarshalException n ClassNotFoundException in RMI
By anuj_1983 in forum New To JavaReplies: 0Last Post: 07-09-2008, 12:36 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks