Ah  my son, I just start with the jswdk-1.0 days ago with the same problems
you had.  But have overcome these pit falls with victory.  I also posted the
solution to the Java Develper Connection.  See posting on "setting classpath
in java" below.  Your problem stated in the email is definitely due to net
having your classpath set to all the libraries your need. In your case you
are missing the tools.jar and/or the j2ee.jar (j2ee.jar if you downloaded the
entriprise edition, may be called jsdk.jar or even something else if you
downloaded the servlet runner utility). See the Setting Classpath in Java
(below) and that should clear up the classpath problem.

Second, let me know what the file name is the has the JAVA_HOME in it (if you
know).




Setting Classpath in Java


When using JDK 2 platform Enterprise edition which includes the Servlet
packages you must
                               include the j2ee.jar file in your
classpath.

                               If you don't you will get errors when
using javac (i.e. javac MyServlet.java) that it can't find the
                               imports (i.e. import javax.servlet not
found).

                               How to do this if you are using Windows
(dos). There are two ways I know of. First, you can set
                               the classpath at the command prompt (Open
a msdos prompt, i.e. C:\> ,the directory does not
                               matter). At the command prompt type
C:\>set classpath=C:\j2sdkee\lib\j2ee.jar; Where j2sdkee is
                               the directory where you installed the JDK
2 Enterprise Edition. This will get the imports you need
                               for the Enterpise Edition classes
including the import javax.servlet

                               All the sun documentation I have read
always recommends that you set the classpath at the
                               command prompt. Why, I don't know for
sure but I have noticed that when you set it in the
                               autoexec.bat file, it does not always
work properly. If you are like me, you hate typing all that stuff
                               on the command line. I put it in the
autoexec.bat file and if I am having problems with it finding the
                               imports then I set it at the command
prompt after first clearing it by doing this C:\>set classpath=
                               Then do as I have showed above. If you
want to add additional files locations to your classpath
                               just do this C:\>set
classpath=%classpath%;C:\j2dk1.2.2\lib\tools.jar where c:\j2dk1.2.2\lib\
is
                               whatever new path you want to add. The
%classpath% lets you append C:\j2dk1.2.2\lib\tools.jar
                               to the end of the class path you already
created. In essence it is the same as retyping C:\>set

classpath=j2sdkee\lib\j2ee.jar;C:\j2dk1.2.2\lib\

                               If you are setting your classpath in the
autoexec.bat file it should look something like this: SET

CLASSPATH=C:\JDK1.2.2\lib\tools.jar;C:\j2sdkee\lib\j2ee.jar

                               Another thing worth mentioning, lets say
you have created your own class or package and want
                               to import (i.e. import MyCreatedClass)it.
You need to add it to your classpath if it is not in the
                               same directory you are doing javac
FileWithImport.java in. I would just add the complete path to
                               the directory with the %classpath% so you
don't loose the classpath you may have already set.

                               Hope this helps someone. I know it took
me a little bit to get it all sorted out and was hoping to
                               avoid spent time for someone else.




Jason Skipper wrote:

> Win95... I have since "SET JAVA_HOME = c:\jdk1.1.7"
> but i am getting java.lang.NoClassDefFoundError: sun/tools/javac/Main
> what do ya think?
> thx
> ~skip
>
> J wrote:
>
> > Are you using windows or a unix based system?
> >
> > Jason Skipper wrote:
> >
> > > ok so i'm having trouble starting my first jsp... i downloaded and
> > > installed the kit .. i think my problem is that i haven't set the
> > > JAVA_HOME variable... but my real problem is HOW do i set it???? It's
> > > not finding the tools so any help will be greatly appreciated =)
> > > ~skip



Reply via email to