JAVA CLASSPATH PROBLEM

JAVA CLASSPATH PROBLEM

hi all Friends

I am stuck using the java servlets and problem raise for classpath.

I had a problem with servlet to call a class because when i complied my servlet class file it give me error that it didn't found any java class (which is java class calling from servlet).

but i solved this problem by putting the path of classes to the classpath and then it worked fine after doing that and my all files compiled fine and my project worked.

But now i am again trying another project and trying to compile this project but got same problem again. Now this time i doing the all procedure for setting the classpath to solve the problem as i solved for previous project. but this time my classpath solution is not working for this project and i am trying this procedure again and again but i don't know i am stuck please help me friends

thanks in advance SANTBIR SINGH

View Answers

July 20, 2012 at 3:25 PM

Put servlet-api.jar inside the lib folder of apache tomcat.

1)create a servlet.

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class HelloWorld extends HttpServlet{ 
  public void doGet(HttpServletRequest request, HttpServletResponse response)
                                   throws ServletException,IOException{
    response.setContentType("text/html");
    PrintWriter pw = response.getWriter();
    pw.println("<html>");
    pw.println("<head><title>Hello World</title></title>");
    pw.println("<body>");
    pw.println("<h1>Hello World</h1>");
    pw.println("</body></html>");
  }
}

2)Go to the webapps folder of your apache tomcat and create a web application folder but it should having an appropriate name like examples.

3)Create web.xml and classes folder inside the WEB_INF folder of web application folder.

4)Copy the servlet to the classes folder.

5)Edit the web.xml to include servlet?s name and url pattern.

 <servlet>
  <servlet-name>HelloWorld</servlet-name>
  <servlet-class>HelloWorld</servlet-class>
 </servlet>
 <servlet-mapping>
 <servlet-name>HelloWorld</servlet-name>
 <url-pattern>/HelloWorld</url-pattern>
 </servlet-mapping>

6)Compile your servlet.

7)Run Tomcat server by clicking the startup.bat file. This is located inside the bin folder of apache tomcat.

8)Open the browser and type the following url:

http://localhost:8080/webapplicationfolder_name/HelloWorld

For more information, please go through the following links:

http://www.roseindia.net/servlets/introductiontoconfigrationservlet.shtml

http://www.roseindia.net/servlets/HowToRunAServlet.shtml









Related Tutorials/Questions & Answers:
JAVA CLASSPATH PROBLEM
JAVA CLASSPATH PROBLEM  hi all Friends I am stuck using the java servlets and problem raise for classpath. I had a problem with servlet to call... solved this problem by putting the path of classes to the classpath
Java classpath
Java classpath  What is the difference between classpath and path variable
Advertisements
Classpath - Java Beginners
Java classpath setting command line  Is there any command line to set the classpath in Java
running java with classpath in cygwin
running java with classpath in cygwin  The following command works in cmd.exe but failts in cygwin shell. java -cp .;oracle.jar;mysql.jar Executecmd query value; how should i alter the command to run in the bash shell?thanks
CLasspath
,ADS_TO_REPLACE_2 Classpath is Environment Variable that tells JVM or Java Tools...CLasspath  what is classpath?   The <B>Classpath... an environment variable. That tells the Java Virtual Machine where to look for user
CLasspath
CLasspath  what is classpath?   Hello, Classpath is Environment Variable that tells JVM or Java Tools where to find the classes. In CLASSPATH environment you need to specify only .class files (i.e., jar, zip files
java classpath prbm in windows 7
java classpath prbm in windows 7  i have a problem to set the classpath in windows7 in my system oracle is not there. environment variables under that user variables i set them like this: CLASS .;C:\Program Files\Java\jdk1.6.0_32
setting classpath of tomcat - Java Beginners
setting classpath of tomcat  hello i am giri. I Installed the Tomcat6 in my system and the problem is, How to set the classpath, Please give...;System->Environment Variables-> and set the CLASSPATH C:\Program Files
Java ClassPath
Java ClassPath      ...  C:\Java\jdk1.6.0_03\lib ADS_TO_REPLACE_5 For setting CLASSPATH using command prompt  Java class path can be set using either the -classpath option
How to set CLASSPATH in Java?
;    In Java you have to set PATH and CLASSPATH variables... directories and JAR archives. The -classpath option to javac and java allows multiple...; In JDK the CLASSPATH contains directories (or JAR files), from where your java
path classpath
be in path. While Classpath is Enviroment Variable that tells JVM or Java Tools where...path classpath  EXPLAIN PATH AND CLASSPATH ? DIFF send me ans plz...://www.roseindia.net/java/java-classpath.shtml Thanks
Maven dependency for com.portingle - classpath-hell version 1.2 is released. Learn to use classpath-hell version 1.2 in Maven based Java projects
use this version ( com.portingle - classpath-hell version 1.2 ) in their Java...Maven dependency for  com.portingle  - Version 1.2 of classpath-hell released The developers of   com.portingle - classpath-hell project
ClassPath Helper
ClassPath Helper       Every developer who has used Java is familiar with the classpath. Usually it doesn't take long to generate your first
java Problem
java Problem  I want to create a binary tree for displaying members in Downline. i am creating a site for MLM(Multi-Level MArketing). tree must be dynamically populated from database. is there any help for me. Thanks in advance
JAVA Problem
JAVA Problem  Write a program that takes two parameters 1. a word 2. an array of words It should then remove all instances of the word in the array. For Example: INPUT word="ravi" word_array = ["Chethan Bhagat
STRUCT CLASSPATH - Struts
STRUCT CLASSPATH  What is the STRUCT CLASSPATH
Compilatation problem - Java Beginners
but after installing 1.4 and setting up the classpath also i am getting... is not installed properly or classpath is not properly set. Please visit the following link: http://roseindia.net/java/learn-java-in-a-day/download-and-install
resolution problem in java
resolution problem in java  I designed project in java in my PC when run the same project in some other PC i can't fully view my java forms.Some said that it is resolution problem
Installing the Driver and Configuring the CLASSPATH
Installing the Driver and Configuring the CLASSPATH  What is the procedure to Installing the Driver and Configuring the CLASSPATH mysql jdbc connector? the jar file
java programming problem - JDBC
java programming problem  Hi, Request you to provide the source code in Java for the following programming problem : upload .csv file data into oracle database. please send the solution to [email protected]
Problem in uploading java application
Problem in uploading java application  I have uploaded my java application (folder created under webapps) using Filezilla FtpClient.Application... this problem
for a problem in coading - Java Beginners
for a problem in coading  what is the problm in following coading...(String[] args) { mywindow (); } }   Hi Friend, There is no problem... mywindows.java Run : java mywindows Thanks RoseIndia Team
classpath and path for structs1.3.8
classpath and path for structs1.3.8  How to set classpath and path for structs1.3.8 ?   just add struts-core-1.3.8.jar file to CLASSPATH or ext folder of jdk installation(\jre\lib\ext folder) and add 10 jar files(main
Multiplication problem - Java Beginners
Multiplication problem  I am facing a peculiar problem in java regarding a multiplication. Please see below: 19300 * 0.001 = 19.3 19400 * 0.001 = 19.400000000000002 (why is this ??) 19500 * 0.001 = 19.5 Can anybody help
java input problem - Java Beginners
java input problem  I am facing a Java input problem
Java Problem - JSP-Servlet
Java Problem  How to run a Simple JSP program ? what steps are necessary  Hi Friend, Steps: 1)First of all you need to install Tomcat... the classpath in Environment variables. 4)Create a web application folder inside
code problem - Java Beginners
java script j2ee j2me sql plz help me to sort out this problem. thnx  ...code problem  Dear sir, I'm havin a problem that suppose i've got a file that contains the following lines- java java script j2ee php sql
Problem on JAVA Programme
Problem on JAVA Programme  public class AA { int add(int i) { int y = i; y += 20; if (y <= 100){ y +=30;add(y);} System.out.println("Final Value of y : " + y); return y; } public static void main
java programming problem - JDBC
java programming problem  Hi, Request you to provide a solution... problem to the following mail id : Problem : upload excel file data into oracle database using java / j2ee. mail id : [email protected]
Java Problem - Java Beginners
Java Problem  Write a program 2 input a positive integer n and check wheter n is prime or not and also know the position of that number in the prime..., Code to solve the problem : import java.io.*; public class PrimeNumber
Servlet compilation problem - Java Beginners
Servlet compilation problem  hi, m a beginner to servlet world... i m facing problem in servlet compilation problem.. i have set the classpath of servlet-api.jar . m using tomcat 6.0 i m unable to compile my servlet program
Java implementation problem
/answers/viewqa/Java-Beginners/28578-java-implementation-problem-.html...Java implementation problem  I want to implement following in java... problem in your post previews. please consider 1. 2. points just after main
code problem - Java Beginners
; Hi friend, Code to help in solving the problem : import java.io.... in Java visit to : http://www.roseindia.net/java/example/java/io/ Thanks
java implementation problem
java implementation problem   I want to implement following in java code : Main thread Create three threads wait for completion of stage 2 of all three threads Access all three local variable (LC0, LC1, LC2) of threads bulid
code problem - Java Beginners
code problem  Dear sir, I have an excel file in D: drive called today.xls, i want to open it thru java program, what code would be compatible plz help me  Hi friend, Code to help in solving the problem : import
problem 1 - Java Beginners
problem 1   Hi, please help me!!!! How can i code in java using Two-dimensional Arrays? This question is related to the one i posted before. this is my input data file: 88 90 94 102 111 122 134 75 77 80 86 94 103 113 80
Basic problem for Java experts
Basic problem for Java experts  This assignment will test your knowledge of Arrays Array searching Array sorting Array processing Specification An athletics club require a simple statistical analysis program for analysing lap
problem with main - Java Beginners
problem with main   import javax.swing.*; import java.awt.... a problem. when i compile it appears this message: java.lang.NoSuchMethodError: main... it with html file. applet.html: Java Applet Demo Thanks
code problem - Java Beginners
code problem  Dear sir, my problem is that I've a string value if this String value has "quit" then output should be "bye". i want to make this program using SWITCH CASE statement. how to implement String value in Switch plz
Bid Problem - Java Beginners
in this application explain in details : Code to help in solving the problem...!"); } } } For more information on Java visit to : http://www.roseindia.net/java/ Thanks
Problem with code - Java Beginners
Problem with code  Hi Deepak. Im a newbie here at your forum. I have got a simple code of mine which is having a little problem. When I compile it, i get an...,identifier expected'...error. Could you help me out? Thank you
Problem in coding - Java Beginners
Problem in coding  How many times do you have to roll a pair of dice before they come up snake eyes? You could do the experiment by rolling the dice... friend, Code to help in solving the problem. public class Stimulates
problem - Java Beginners
in java if want something like this using array?   Hi friend, Code to solve the problem : import java.io.*; public class JavaMeanDeviation
problem - Java Beginners
in java if want something like this using array?   Hi friend, Code to solve the problem : import java.io.*; public class JavaMeanDeviation
code problem - Java Beginners
code problem  Dear sir, My problem is that i have some string value and in some case i want to remove all the value of this string, i tried this code- Response.str.clear(); but it shows some error called "response package
code problem - Java Beginners
code problem  Dear sir, my problem is given below: suppose a file Carries the following lines- Name: john age: 45 Address: goa phone...; Hi friend, Code to help in solving the problem : import java.io.
Problem with picture - Java Beginners
Problem with picture   Hi, I Develope a School Automated System that takes a details from the user interface and deposited into the database (MSSQL), i make the registrar to be able to upload the student picture from
Problem with picture - Java Beginners
Problem with picture   Hi, I Develope a School Automated System that takes a details from the user interface and deposited into the database (MSSQL), i make the registrar to be able to upload the student picture from
code problem - Java Beginners
your problem in details. Which keyword search the line. Thanks
Problem in java 1.6 - Java Beginners
Problem in java 1.6  Am facing problem in java 1.6 . Ex. In a Frame......  Hi friend, Give source code where you having the problem For read more information on java visit to : http://www.roseindia.net/java

Ads