Setting Classpath for JSDK

Posted on 2000-03-07
Last Modified: 2013-11-23
How do I set the Classpath for JSDK in Solaris. I am very new to
using Servlets. I installed  JSDK2.1 in Solaris. But evertime I compile
any servlet, I get the following error:

" Package javax.servlet not found in import.
import javax.servlet.*;
       ^ Package javax.servlet.http not found in import.
import javax.servlet.http.*;
       ^ Superclass HttpServlet of class SessionServlet not found.
public class SessionServlet extends HttpServlet {"


I have a deadline to meet, somebody please help me and let me know
what I need to do in order to get this servlets compiling and executing.
Question by:bmeena71
  • 9
  • 8

Accepted Solution

cheneque earned 50 total points
ID: 2593004
You can add the file servlet.jar to the CLASSPATH enviroment variable. For example:

CLASSPATH = $CLASSPATH:/opt/jsdk1.2/servlet.jar

or you can edit the .java_wrapper file in the java/bin subdirectory adding the complete path of the servlet.jar file.

If you need anymore just say it.

Author Comment

ID: 2593441
Hi Cheneque,

Thanks a lot for responding. I have installed
JSDK version 2.0 and I could not find any servlet.jar
file. I could find jsdk.jar

And also where should I set the classpath. Is there
a file I should add this in. As of now the classpath
settings exist in a file called  .profile

Your help is appreciated.

Expert Comment

ID: 2593539
Yea, you can add the CLASSPATH enviroment variable in your .profile file. but I recommend you use a enviroment configuration script if you are developing various applications.

I´m using jdk1.1.7 and the shell csh and I created a file called "", in this file I add all the directories or jar files that I use for my applications. My file look lije this:

#here is the classpath for my applications.
setenv CLASSPATH /home/cheneque/applications/classes:/home/cheneque/lib/servlets.jar:/home/cheneque/lib/jndi.jar
I call this file using the following command.

$ source

In this way I can configure a lot of applications in a unique UNIX account.

P.D. the servlets.jar file is part of the jsdk2.1

Author Comment

ID: 2598004
Hi Cheneque,

I tried what you recommended. I created an env file and did
set the classpath exactly as you have mentioned. But I get
"setenv not found" and when I do 'source' I get "source not
found" errors.

My company's unix admin is out of town and I just have basic
Unix knowledge.

I still am at a loss of how to configure this.  Any help??

Expert Comment

ID: 2598203
what sell are you using?
-- csh
-- bash
-- sh
or another one? you can know this whit the following command:
$ echo $SHELL

I´m running "csh" and it works fine if you are running another shell maybe the thinks are diferent. see the man pages of your shell for more information.

Maybe you are using "sh" or "bash" you can use "export" instead "setenv".

Say me the shell and your subdirectories and I create a enviroment file for you.

Author Comment

ID: 2598323
When I do echo $SHELL  I get /bin/sh

and the directory where JSDK2.0 installed is as follows


Looking forward for your reply.

Thanks for being so patient with me.


Author Comment

ID: 2602324
Would you still be able to help me.
thanks- M

Expert Comment

ID: 2602665
Hi, I create a script for you, but you can´t use the enviroment variables of the sell from a file because you ar running "sh" but it dont matter. This script you have to complete with your options:

---------- cut after this line ---------------------

#Here is the  jsdk classpath

#Here we put the application classpath
#(This line is comented because you have to fill this line with the classpath of the application that
# you are developming)

#We set the complete application classpath and libraries

#Now we Export the variables

#At this moment we are ready to start the application server,
#I'm using weblogic and to start it i put the following line
# java weblogic.T3Server &
#This is FOR ME you have to write the correct line or if you have a previus
# script to start your application server put this here.

----------------------finish ----------------

If you change to "csh" you can use the following script

---------------------------------- cut after this line -----------------------

#Here is the  jsdk classpath
setenv SERVLETS_CLASSPATH /jrun2.2/JSDK2.0/lib/jsdk.jar

#Here we put the application classpath
#(This line is comented because you have to fill this line with the classpath of the application that
# you are developming)
setenv APPLICATION_CLASSPATH here_put_your_options_be_careful_with_the_blank

#We set the complete application classpath and libraries

---------------finish -----------------

With the second script you use the "source" comand to read it, the source comand is avalible when you are in csh

Good luck
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.


Expert Comment

ID: 2602669
Note: With the "sh" option you can´t read variables to the shell from a script, you have to call the application in the script to make the enviroment works with your aplication

Author Comment

ID: 2606444

I did as you said and I am able to compile the servlets now. Thanks a lot for
your help.

Now when I execute the servlet - a servlet called SnoopServlet from the examples this is what I get

"java.lang.NoSuchMethodError: javax.servlet.ServletResponse: method getWriter ()Ljava/io/PrintWriter; not
found at SimpleServlet.doGet( * at
javax.servlet.http.HttpServlet.service( at
javax.servlet.http.HttpServlet.service( at at
netscape.server.applet.ServerApplet.handleRequest( at
netscape.server.applet.HttpApplet.handleRequest( "

Am I still missing something here.

Thanks a lot,

Expert Comment

ID: 2613555
The problem is with the class, maybe you are ommiting the archive in your classpath.

If you are using the -classpath option when you start your server you have to put all the files.


Expert Comment

ID: 2613561
the archive are in the $JAVA_HOME/lib subdirectory

Author Comment

ID: 2614057

I could find the archive file

the directory path for that is /usr/java1.1/lib/

My alread existing classpath looks like this:

CLASSPATH=/jrun2.2/JSDK2.0/lib/jsdk.jar; export CLASSPATH

echo "\nWelcome home, Meena!\n"

Now I added the classpath for the file and it looks as

CLASSPATH=/jrun2.2/JSDK2.0/lib/jsdk.jar:/export/home/mxb80/java1.1/lib/; export CLASSPATH

echo "\nWelcome home, Meena!\n"

Now I execute the servlet called SimpleServlet, I get the same error message.  Please let me know if I am still doing something wrong/


Expert Comment

ID: 2618086

Maybe you don´t have the jsdk, try downloading the jsdk 2.0 form the javasoft site and puting the servlet.jar file in your CLASSPATH.

Other solution is install netbeans or forte for develpment. both IDE´s have a servlet developmet module and the good news are:  both applications are for free in the site.

You can develop, debug and run your servlets in a testing enviroment.


Author Comment

ID: 2620563

This is a very good recommendation you have told me. Thanks a lot
for that. I also happened to find out what was going wrong in my
servlet. I am using an old version of Netscape(3.63) and it doesn't
support  PrintWriter I believe and that is the reason I was getting
"java.lang.NoSuchMethodError: javax.servlet.ServletResponse: method getWriter  ()Ljava/io/PrintWriter; not found" ---error.

Instead I changed my program and used. getOutputStream() method
and I was able to successfully compile and execute it. But I will
now download Netbeans or Forte. This way I will be able to test
my servlets.

My next step is to connect to database thru jdbc:odbc.  I will get in
touch with you if I encounter any problems.

Thanks a lot for all your help.

Expert Comment

ID: 2624313
Net beans or forte have modules to use JDBC and wizards to connect to a data base. Is a very good tool !!!

Good look !!

Author Comment

ID: 2624933

Once again, thankx a lot for giving me excellent tips.

When my code for servlet is being executed, "oracle.jdbc.driver.OracleDriver" throws a nullPointerException.

My code gets compiled and when I am tail-ing the error log,
I noticed that when it comes to the above line of "oracle.jdbc..."
I get a null value.  

what am I missing?

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now