The Artima Developer Community
Sponsored Link

Java Answers Forum
set up classpath to find packages

2 replies on 1 page. Most recent reply: Apr 24, 2002 12:37 PM by Diane Tang

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
Diane Tang

Posts: 6
Nickname: yiju
Registered: Apr, 2002

set up classpath to find packages Posted: Apr 23, 2002 11:46 AM
Reply to this message Reply
Advertisement
1) I create a "Plot" folder under the root directory to store the packages I wrote, and add the command line
"set classpath=.;c:\;" in autoexec.bat.
2) Then I add the line "import Plot.*;" in every java source.

I can compiler successfully. But the problem is when running the applet, I got the following error message and the applet won't be initialized:

Exception:java.lang.NoClassDefFoundError Plot/(package)

Any help will be appreciated.


Kishori Sharan

Posts: 211
Nickname: kishori
Registered: Feb, 2002

Re: set up classpath to find packages Posted: Apr 23, 2002 2:47 PM
Reply to this message Reply
For applet, you have to set the CODEBASE attribute. Now, CODEBASE + "\" + CODE should have the path to the .class file. You don't get such problem if your applet's class file and html file containing the applet tag are placed in the same folder and your applet class in not in a package. This is because by default CODEBASE is used as the folder from where html page is opened. Since you have placed your applet class in a package, you need to set the appropriate CODEBASE to lead IE to the class file. I had got this problem when I was testing an applet on local PC and setting approrpiate CODEBASE was the solution.

Thanks
Kishori

Diane Tang

Posts: 6
Nickname: yiju
Registered: Apr, 2002

Re: set up classpath to find packages Posted: Apr 24, 2002 12:37 PM
Reply to this message Reply
Thanks for your answer.

However the problem I had is that I created an applet
which using "import" command to access the package from other directory and set the classpath as above. I'm very confused that I can compile the applet successfully which means it can find the package. Why
did I get the error message like "cannot find" in IE?
Does it mean it's not consistent in Dos & window environment? Thanks.

Flat View: This topic has 2 replies on 1 page
Topic: getAttribute/setAttribute in jsp Previous Topic   Next Topic Topic: events in java

Sponsored Links



Google
  Web Artima.com   

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