Home Answers Viewqa Java-Beginners JAVA CLASSPATH PROBLEM

 
 


santbir singh
JAVA CLASSPATH PROBLEM
1 Answer(s)      10 months ago
Posted in : Java Beginners

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 Pages:
CLASSPATH
detail. CLASSPATH tells Java where to search for programs Where to look... the environment variable CLASSPATH, which Java uses to see where it should find Java programs... to search, and double-clickable Jar (Java Archive) files don't have this problem
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
CLasspath
variable. That tells the Java Virtual Machine where to look for user-defined classes and packages when running Java programs.   Hi Friend, Classpath...CLasspath  what is classpath?   The <B>Classpath
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
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 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
Checking Classpath Validity - Java Tutorials
Checking Classpath Validity 2001-12-13 The Java Specialists' Newsletter... if you are used to case-insensitive NT paths. The classpath problem is so... to be -classpath. set ERRORLEVEL=1 goto end ) ) java
Java classpath
Java classpath  What is the difference between classpath and path variable
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
Java ClassPath
Java ClassPath      ... archives. The -classpath option to javac and java allows multiple entries.... i.e.classpath  C:\Java\jdk1.6.0_03\lib For setting CLASSPATH using command
Classpath - Java Beginners
Java classpath setting command line  Is there any command line to set the classpath in Java
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
Set classpath and "commons-fileupload.jar" - JSP-Servlet
Set classpath and "commons-fileupload.jar"  Hi, Thanks for the quick reply to my question on "Java compilation error".. As you said, i have...)..where should i place it, and also confuse at the setting classpath, please guide
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
problem
problem  Hi, what is java key words   Hi Friend, Java Keywords are the reserved words that are used by the java compiler for specific... information, visit the following link: Java Keywords Thanks
problem
problem  hi'sir mai niit student hu.mujhe java ka program samaj me nhi aata mai kya karu and mai kaise study karu please help me.   Learn Java from the given link: Java Tutorials
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
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
problem in setting path - Ant
problem in setting path  hi friends i am getting a problem in setting...:\installations\java\JDK\bin;.; and the javapath as JAVA_HOME=D:\installations\java\JDK...:\installations\apache-ant-1.7.1-bin\apache-ant-1.7.1\bin;D:\installations\java\JDK\bin
STRUCT CLASSPATH - Struts
STRUCT CLASSPATH  What is the STRUCT CLASSPATH
RichFaces problem - Java Server Faces Questions
RichFaces problem  RichFaces problem and error  Hi... signatures. ie: you have the same class twice in your CLASSPATH, but the classes... this problem by deleting el-api.jar and el-impl.jar (because there is another version
setting path problem for org.jfree files - Java Beginners
setting path problem for org.jfree files  Hi deepak, As u said, i... with org.jfree files and i have given the classpath as folllows... C:\Program Files\Java\j2sdk1.5.0\bin;C:\Program Files\Java\j2sdk1.5.0\lib\jcommon-1.0.8.jar;C
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
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
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
What is difference between Path and Classpath?
What is difference between Path and Classpath?   hi What is difference between Path and Classpath? thanks   Hi, The Path & Classpath are used for operating system level environment variales. We mostly use Path
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
problem with package
problem with package  Dear sir, i have created one java file with package com.net; and i compiled the program.it showing the .class file in " net" folder.The problem is i want to use that .class file in some other
java input problem - Java Beginners
java input problem  I am facing a Java input problem
getting an error when set classpath
getting an error when set classpath  Hello Everyone! i have used hssf model for reading excel sheet in my project & i have set classpath for that jar file but when i compile the program it will compile correctly but when i
Java problem - Java Beginners
Java problem  what are threads in java. what are there usage. a simple thread program in java  Hi Friend, Please visit the following link: http://www.roseindia.net/java/thread/index.shtml Thanks
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
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 raichallp@yahoo.in
problem in coding
problem in coding  i have a following code which display the contents of the text file but not other program like java or any c program is there any handler to open the program files other than Filereader. FileReader fr = new
Java problem - Java Beginners
Java problem  I have an image in my application and I need to restrict the image path view on the browser. Noone should be able to right click and see the image path. Please help
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
Java Problem - Java Beginners
Java Problem  How to create executable file of a java program.That is steps to create a Jar File of a Java Program  Hi Friend, Try the following code: import java.io.*; import java.util.jar.*; public class
java problem - Java Beginners
java problem  Write a program to model a simple calculator. Each data line should consist of the next operation to be performed from the list below.../java/example/java/swing/calculator-in-swing.shtml Thanks
java problem - Java Beginners
java problem  Suppose list is an array of five components of the type int.What is stored in list after the following Java code executes? for (i = 0; i < 5; i++) { list[i] = 2 * i + 5; if (i % 2 == 0) list[i] = list[i
Problem with arraylist
Problem with arraylist  I am currently working on a java project and there is an if loop within the for loop.... for(int i = 1;i < iterationsNo.... It seems that 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
JAVA Problem - Java Beginners
JAVA Problem  please help me!!!! How can i code in java using Two-dimensional Arrays? 88 90 94 102 111 122 134 75 77 80 86 94 103 113 80 83 85 94 100 111 121 68 71 76 85 96 110 125 77 84 91 98 105 112 119 81 85 90 96 102
PROBLEM IN EXECUTION
PROBLEM IN EXECUTION  class R { private int x; private int y; void getdata(int x1,int x2) { x=x1; y=y1... PRIVATE ACCESS IN R   Java Program Private modifier does not allow
uploading problem
;charset=UTF-8" language="java" %> <%@ page import="java.io.*,java.sql.*,java.util.zip.*" %> <%@ page language="java" import="java.util....(); } } } } %> my problem...: firstly
java problem - Java Beginners
java problem  a) Binary numbers is important in computers. Binary number system uses only two digits, 0 and 1. There are pre-defined methods available in Java that will allow us to convert from denary integer (base 10
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 Problem - Java Beginners
Java Problem  How to create a jar file of a program  Hi Friend, Try the following code: import java.io.*; import java.util.jar.*; public class CreateJar { public static int buffer = 10240; protected void
java problem - Java Beginners
java problem  Hotel.java This file declares a class of object which maintains a collection of Room objects. It will contain methods which enable... from a small Java program
java problem - Java Beginners
java problem  Room.java This file defines a class of Room objects. The objects have the following instance variables:  number of beds in the room... from a small Java program. HotelMain.java The aim of this class is to provide

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.