?
Solved

Error in compiling java program

Posted on 2003-03-24
11
Medium Priority
?
288 Views
Last Modified: 2013-11-23
Dear all,

     I am a beginner in java. I tried to compile one java program but encounter the following errors:
     error J0051: Undefined package 'servlet'
     error J0051: Undefined package 'http'

     How should I solve it? The compiler i am currently using is microsoft j++ 1.1
     Thank you.

Regards,
eliza
0
Comment
Question by:elizateh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +3
11 Comments
 
LVL 2

Expert Comment

by:amit_chauhan
ID: 8199699
Put servlet.jar in classpath while compiling.
sevlet.jar contains javax.servlet.http package. If its not servlet.jar, then find any other jar that contains it. Still cant find it, then download this from java.sun.com. BTW, this package is now a part of J2SDK1.4. Before that it used to come as a separate jar (as an extension)

Hope that helps
Thanks
Amit
0
 

Author Comment

by:elizateh
ID: 8200112
Dear amit,

     Thank you for the prompt reply. I have one servlet.jar file in this directory C:\jswdk-1.0.1\lib. So, i include this in the classpath. but the error still remains. What should i do next?

Thank you
0
 
LVL 2

Expert Comment

by:amit_chauhan
ID: 8200125
Can you cut-paste the whole exception that you are getting.
Also how you are compiling this file ? from command prompt ? or from the tool itself ?
Also open servlet.jar using winzip and check for the directory javax/servlet/http in the path section. It should be there.
0
Quick Start: DOCKER

Sometimes you just need a Quick Start on a topic in order to begin using it.. this is just what you need to know to get up and running with Docker!

 

Author Comment

by:elizateh
ID: 8200275
Dear amit,

     the following are the exception:

ompiling...
Microsoft (R) Visual J++ Compiler Version 1.01.7022
Copyright (C) Microsoft Corp 1996. All rights reserved.
C:\jswdk-1.0.1\examples\WEB-INF\servlets\HelloWorldKr.java(8,8) : error J0051: Undefined package 'servlet'
C:\jswdk-1.0.1\examples\WEB-INF\servlets\HelloWorldKr.java(9,8) : error J0051: Undefined package 'http'
Error executing jvc.exe.

HelloWorldKr.class - 2 error(s), 0 warning(s)

Line 8 and 9 are:
import javax.servlet.*;
import javax.servlet.http.*;

I am compiling this file from the j++1.1 tool itself

I have opened servlet.jar using powerarchiver and  i did find many class files under the directory javax/servlet/http in the path section.

I have included this servlet.jar in the classpath under the environment variables.  Currently the classpath variable is pointing to:
C:\jdk1.3\lib\tools.jar; C:\jswdk-1.0.1\lib\servlet.jar

Thank you.


0
 
LVL 2

Accepted Solution

by:
amit_chauhan earned 440 total points
ID: 8201153
Hi,
Try to compile it from command line by giving explicit classpath:

C:\>javac -classpath %CLASSPATH%;C:\jswdk-1.0.1\lib\servlet.jar HelloWorldKr.java

check if the error still comes.
0
 
LVL 9

Expert Comment

by:Venci75
ID: 8201166
put your servlet.jar to the %JAVA_HOME%\lib\ext directory
0
 
LVL 4

Expert Comment

by:kokchoon78
ID: 8201275
Hi,

   Visual J++ will use their own JVM called jvc.exe. When your program runs from within the Visual J++ development environment, the VM includes the information entered into the Java Packages tab of Settings dialog box when searching for .class files. Access the Java Packages tab from the Project menu's Settings dialog box.

regards,
Kok Choon.
0
 
LVL 35

Expert Comment

by:girionis
ID: 8201513
0
 

Expert Comment

by:ajaycv
ID: 8201774
I guess u haven't set ur environment variables properly. May I know which OS u r using VJ++ on?

Ajay.
0
 

Expert Comment

by:ajaycv
ID: 8201806
Use this to set the classpath:

On the Project menu, click Properties.
In the Project Properties dialog box, click the CLASSPATH tab.
Click New, and then type the fully-qualified path name for including the servlet.jar file.

Ajay.
0
 

Author Comment

by:elizateh
ID: 8207163
Thank you very much. It did work! Thank you for the explanation as well. But yet to try to compile it from the tools itself...
0

Featured Post

Cloud Training Guides

FREE GUIDES: In-depth and hand-crafted Linux, AWS, OpenStack, DevOps, Azure, and Cloud training guides created by Linux Academy instructors and the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses
Course of the Month8 days, 12 hours left to enroll

764 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