LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu
User Name
Password
Ubuntu This forum is for the discussion of Ubuntu Linux.

Notices

Reply
 
Search this Thread
Old 07-03-2005, 06:47 AM   #1
twistedrhymes
LQ Newbie
 
Registered: Jun 2005
Distribution: redhat/koppix
Posts: 23

Rep: Reputation: 15
Question java install help (heading towards tomcat)


javac -version = javac 1.5.0_03

java -version =
java version "1.5.0_03"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_03-b07)
Java HotSpot(TM) Client VM (build 1.5.0_03-b07, mixed mode, sharing)

i have my basic java servlet saved as Hello.java

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

public class Hello extends HttpServlet {

  public void doGet(HttpServletRequest req, HttpServletResponse res)
                               throws ServletException, IOException {

    res.setContentType("text/html");
    PrintWriter out = res.getWriter();

    String name = req.getParameter("name");
    out.println("<HTML>");
    out.println("<HEAD><TITLE>Hello, " + name + "</TITLE></HEAD>");
    out.println("<BODY>");
    out.println("Hello, " + name);
    out.println("</BODY></HTML>");
  }

  public String getServletInfo() {
    return "A servlet that knows the name of the person to whom it's" + 
           "saying hello";
  }
}

when i try to javac Hello.java it throws about 6-7 errors.
i'm not sure if its something i've installed, most likely the way its set up!

my errors are!

Code:
mark@dev:/var/www$ javac Hello.java
Hello.java:2: package javax.servlet does not exist
import javax.servlet.*;
^
Hello.java:3: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
Hello.java:5: cannot find symbol
symbol: class HttpServlet
public class Hello extends HttpServlet {
                           ^
Hello.java:7: cannot find symbol
symbol  : class HttpServletRequest
location: class Hello
  public void doGet(HttpServletRequest req, HttpServletResponse res)
                    ^
Hello.java:7: cannot find symbol
symbol  : class HttpServletResponse
location: class Hello
  public void doGet(HttpServletRequest req, HttpServletResponse res)
                                            ^
Hello.java:8: cannot find symbol
symbol  : class ServletException
location: class Hello
                               throws ServletException, IOException {
                                      ^
6 errors
so its obviouslly not finding the java path.
can anyone give me a hand? i've been trying to fix this for a few days now, and i'm totally lost
 
Old 07-04-2005, 12:36 AM   #2
mrcheeks
Senior Member
 
Registered: Mar 2004
Location: far enough
Distribution: OS X 10.6.7
Posts: 1,690

Rep: Reputation: 50
you've got to set the classpath.
java -cp /usr/tomcat_directory/common(or server)/lib/servlet-api.jar hello.java.

In java you always have to specify the classpath for any external library you use.
 
Old 03-20-2006, 04:45 PM   #3
xpucto
Member
 
Registered: Sep 2005
Location: Vienna, Austria
Distribution: Mint 13
Posts: 522

Rep: Reputation: 31
I have the same problem eventhough I set the classpath
Quote:
echo $CLASSPATH
/opt/SUNWappserver/jdk/lib:/opt/apache-tomcat/common/lib:/opt/apache-tomcat/bin
if i do
Quote:
javac -classpath /opt/apache-tomcat/common/lib/servlet-api.jar servlet_test1.java
, then it works.
What did I do wrong?

I've just noticed that I'm in the Ubuntu forum. I've moved this post under software where it belongs.

Last edited by xpucto; 03-21-2006 at 07:47 AM.
 
Old 02-10-2009, 06:34 AM   #4
jtopland
LQ Newbie
 
Registered: Apr 2005
Posts: 7

Rep: Reputation: 0
you must explicitly set the path to the jar file, not just the directory
 
Old 08-16-2010, 12:55 PM   #5
abmunguia
LQ Newbie
 
Registered: Aug 2009
Posts: 1

Rep: Reputation: 0
Talking

About this...
Over ubuntu 10.04 I had redefined:

/etc/enviroment with:
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
CLASSPATH=/usr/lib/jvm/java-6-openjdk/bin:/usr/share/tomcat6/lib/(EVERY FUCKING JAR FILE IN THE FOLDER).jaretc...)
JAVA_HOME=/usr/lib/jvm/java-6-openjdk
(EVERY FUCKING JAR FILE IN THE PATH)

and also /home/user/.bashrc with:
export JAVA_HOME=/usr/lib/jvm/java-6-openjdk
export CATALINA_HOME=/usr/share/tomcat6
export CLASSPATH=/usr/share/tomcat6/lib/(EVERY FUCKING JAR FILE IN THE FOLDER).jaretc...)
export PATH=$PATH:$CLASSPATH:$CATALINA_HOME
(EVERY FUCKIN JAR FILE TOO)

But this has no success.

I'm trying to work in Netbeans 6.8, I still recieve the warnings...
Any tip?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Java, apache, tomcat @ngelot Linux - Software 0 11-03-2005 06:55 AM
how to install java & tomcat server in linux adityakumar Linux - Software 2 06-04-2005 11:51 PM
install Java (Servlet), Tomcat on Fedora need help. learn Fedora 2 02-25-2004 12:28 AM
No desktop icons or K-menu heading for programs I install star_bright Linux - Software 4 11-22-2003 10:19 PM
java ant tomcat j-ray Linux - Software 1 09-12-2002 12:59 PM


All times are GMT -5. The time now is 11:49 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration