The Artima Developer Community
Sponsored Link

Java Answers Forum
package BUG !! ??

2 replies on 1 page. Most recent reply: Jan 15, 2003 2:48 PM by Kishori Sharan

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
amitava

Posts: 1
Nickname: softgen
Registered: Jan, 2003

package BUG !! ?? Posted: Jan 14, 2003 12:27 PM
Reply to this message Reply
Advertisement
I wrote a public class Time ( saved it in Time.java ) in a package amit.java.time and another public applet class TimeTest ( saved it in TimeTest.java ) which imports the Time class . Both the class and the applet class code compiled successfully . But when I run the appletviewer from command line the HTML file shows an error that the Time.class is not found .

THE PROCEDURE I FOLLOWED :--

1> I compiled (Time.java) with the command : javac -d \ Time.java

2> Then I set the classpath with the command : set CLASSPATH=\;

3> Next I compiled TimeTest.java with the command : javac TimeTest.java

4> Then I created the html file

<html>
<applet code="TimeTest.class" width=300 height=100>
</applet>
</html>

And I saved it as TimeTest.html

5> Finally I run the appletviewer : appletviewer TimeTest.html

ERROR:--

java.lang.NoClassDefFoundError:amit/java/time/Time

Where is the BUG !!

Handling Packages in java proves to be a difficult affair to me :-)
THANK U.( AMITAVA )


Ugo Posada

Posts: 37
Nickname: binaryx
Registered: Dec, 2002

Re: package BUG !! ?? Posted: Jan 14, 2003 6:52 PM
Reply to this message Reply
I guess you should set your classpath to the path where the folder amit is located. Correct me if i am wrong.

Kishori Sharan

Posts: 211
Nickname: kishori
Registered: Feb, 2002

Re: package BUG !! ?? Posted: Jan 15, 2003 2:48 PM
Reply to this message Reply
Since you have placed your class for applet in a package you need to set the CODEBASE attribute of applet tag in html. Browser has to find the class. By default the value of codebase is ".", which means the current directory from where html file is loaded. So, if you create te package folder setup just beneath the folder where you have stored your HTML file then it will work fine. Alternatively, just set the CODEBASE attribute and place your package folder hierarchy and class file accordingly.

If it doens't fix the problem then read more about CODEBASE attribute. Also, you may just first try to keep class file and html in the same folder and remove package declaration from your class and see if it is running.

Thanks
KIshori

Flat View: This topic has 2 replies on 1 page
Topic: Unreported exception-- Please help :-) Previous Topic   Next Topic Topic: Socket programming with Threads

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use