LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-06-2007, 11:24 PM   #1
me4linux
Member
 
Registered: Aug 2006
Distribution: Fedora 7
Posts: 165

Rep: Reputation: 30
setting classpath and javahome in fedora 5


HI everyone
i am using tomcat Apache Tomcat/5.5.15
when i have compiled my testservlet file i got the following error message
[root@localhost classes]# javac TestingServlet.java
----------
1. ERROR in TestingServlet.java
(at line 1)
import javax.servlet.*;
^^^^^^^^^^^^^
The import javax.servlet cannot be resolved
----------
2. ERROR in TestingServlet.java
(at line 2)
import javax.servlet.http.*;
^^^^^^^^^^^^^
The import javax.servlet cannot be resolved
----------
3. ERROR in TestingServlet.java
(at line 6)
public class TestingServlet extends HttpServlet {
^^^^^^^^^^^
HttpServlet cannot be resolved to a type
----------
4. ERROR in TestingServlet.java
(at line 8)
public void doGet(HttpServletRequest request,
^^^^^^^^^^^^^^^^^^
HttpServletRequest cannot be resolved to a type
----------
5. ERROR in TestingServlet.java
(at line 9)
HttpServletResponse response)
^^^^^^^^^^^^^^^^^^^
HttpServletResponse cannot be resolved to a type
----------
6. ERROR in TestingServlet.java
(at line 10)
throws ServletException, IOException {
^^^^^^^^^^^^^^^^
ServletException cannot be resolved to a type
----------
6 problems (6 errors)[root@localhost classes]#


I found in one of the threads that BY SETTING THE CLASSPATH VARIABLE IT CAN BE RESOLVED

How to set the classpath variable in Fedora core 5
I read i a book that JAVA_HOME variuable also should be assigned a value i.e the poath where java is installed

Please explain me about setting the variable JAVA_HOME,CLASSPATH....etc[IF ANY] in detail

Bye
 
Old 02-07-2007, 12:27 AM   #2
kstan
Member
 
Registered: Sep 2004
Location: Malaysia, Johor
Distribution: Dual boot MacOS X/Ubuntu 9.10
Posts: 851

Rep: Reputation: 31
login as root, edit the following file

/etc/profile

add following line:-

Quote:
export JAVA_HOME=/usr/local/jdk1.5.0_09
export CATALINA_HOME=/usr/local/apache-tomcat-5.5.15
export ... (if you need additional environment parameter)
Please change above detail follow your condition.

Regards,
Ks
 
Old 02-08-2007, 07:46 AM   #3
me4linux
Member
 
Registered: Aug 2006
Distribution: Fedora 7
Posts: 165

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by kstan
login as root, edit the following file

/etc/profile

add following line:-


Please change above detail follow your condition.

Regards,
Ks
THANKS FOR YOUR QUICK REPLY

I dont have the directories that u have specified for java and tomcat
i have them other directory ----- /usr/share
there is a directory named tomcat5 which has all its stuff
/usr/share/tomcat5

there are other directories named
drwxr-xr-x 8 root root 12288 Feb 5 22:59 java
drwxr-xr-x 2 root root 4096 Feb 5 22:42 java-1.3.0
drwxr-xr-x 2 root root 4096 Feb 7 2006 java-1.3.1
drwxr-xr-x 2 root root 4096 Feb 7 2006 java-1.4.0
drwxr-xr-x 2 root root 4096 Feb 7 2006 java-1.4.1
drwxr-xr-x 2 root root 4096 Feb 7 2006 java-1.4.2
drwxr-xr-x 2 root root 4096 Feb 7 2006 java-1.5.0
drwxr-xr-x 17 root root 4096 Feb 5 22:59 javadoc
drwxr-xr-x 2 root root 4096 Feb 7 2006 java-ext
drwxr-xr-x 2 root root 4096 Feb 8 19:12 java-utils

out of these the java ,java-1.3.0[contains symbolic link to a file in java] contain some files
the last one java-utils has a txt file name java_functions
java-1.3.1
java-1.4.0
java-1.4.1
java-1.4.2
java-1.5.0 All these directories are empty

which path should i use for running a servlet???
Please explain me in detail

THANKS IN ADVANCE
 
Old 02-08-2007, 06:25 PM   #4
kstan
Member
 
Registered: Sep 2004
Location: Malaysia, Johor
Distribution: Dual boot MacOS X/Ubuntu 9.10
Posts: 851

Rep: Reputation: 31
Hi me4linux,
normally what I do is:-
1. download jdk (or jre) from sun,
2. extract it into /usr/local (my case is /usr/local/jdk1.5.0_09)
3. download tomcat 5 and extract to /usr/local too (my case is /usr/local/apache-tomcat-5.5.15)
4. force linux use downloaded java rather than built in from particular linux distro (edit /etc/profile)
Quote:
export JAVA_HOME=/usr/local/jdk1.5.0_09
export CATALINA_HOME=/usr/local/apache-tomcat-5.5.15
export PATH=$JAVA_HOME/bin:$PATH
5. logout and relogin
6. type to check whether the version is match to u:
Quote:
echo $JAVA_HOME
java -version
7. Then start the tomcat to see the result.
Good luck.

Regards,
KS
 
Old 03-06-2007, 02:06 AM   #5
me4linux
Member
 
Registered: Aug 2006
Distribution: Fedora 7
Posts: 165

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by kstan
Hi me4linux,
normally what I do is:-
1. download jdk (or jre) from sun,
2. extract it into /usr/local (my case is /usr/local/jdk1.5.0_09)
3. download tomcat 5 and extract to /usr/local too (my case is /usr/local/apache-tomcat-5.5.15)
4. force linux use downloaded java rather than built in from particular linux distro (edit /etc/profile)

5. logout and relogin
6. type to check whether the version is match to u:

7. Then start the tomcat to see the result.
Good luck.

Regards,
KS

Hi kstan

I am downloading
-->jdk-6-linux-i586.bin from sun website[i didnt find tar.gz file]
-->apache-tomcat-4.1.34.tar.gz
-->apache-tomcat-5.5.20.tar
-->apache-tomcat-5.5.20-deployer.tar

Is it enough to install the first 2 packages by the mehtod that u have described???

If so how to install using the Linux self-extracting file "jdk-6-linux-i586.bin "

i have formatted the partion contaning fedora 5 64bit and installed
fedoar 6 -32bit
Even after installing all the packages that are starting with tomcat i am unable to get the default page for tomcat when i run
http://localhost:8080 in the browser
Will i get the default page after installin the above two packages???

WAITING FOR YOUR REPLY

bye for now
 
Old 03-06-2007, 08:00 PM   #6
kstan
Member
 
Registered: Sep 2004
Location: Malaysia, Johor
Distribution: Dual boot MacOS X/Ubuntu 9.10
Posts: 851

Rep: Reputation: 31
simple use this command you can get your java directory at your current folder
sh jdk-6-linux-i586.bin

after you done, extract apache-tomcat-5.5.20.tar to your /usr/local

edit /etc/profile:
export JAVA_HOME=/usr/local/jdk1.6.0_00
export CATALINA_HOME=/usr/local/apache-tomcat-5.5.20
export PATH=$JAVA_HOME/bin:$PATH


after done,
goto tomcat folder /usr/local/apache-tomcat-5.5.20/bin,
run this command:-
./startup.sh

browse to http://localhost:8080/

This should work and Good luck.

Regards,
Ks
 
Old 03-07-2007, 09:52 AM   #7
me4linux
Member
 
Registered: Aug 2006
Distribution: Fedora 7
Posts: 165

Original Poster
Rep: Reputation: 30
Hi kstan


i have installed succesfully and edited /etc/profile by adding new environment values as u has stated
The default page for tomcat is coming
But i am unable to complile the servlet program
the program is as follows
TestingServlet.java
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;

public class TestingServlet extends HttpServlet {

public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {

PrintWriter out = response.getWriter();
out.println("<HTML>");
out.println("<HEAD>");
out.println("<TITLE>Servlet Testing</TITLE>");
out.println("</HEAD>");
out.println("<BODY>");
out.println("Welcome to the Servlet Testing Center");
out.println("</BODY>");
out.println("</HTML>");
}
}

I have saved the file with the name "TestingServlet.java"
and copied it to the directory
/path_to_tomcat/webapps/my_apps/WEB-INF/classes/

when i complile the program in this directory iam getting the following error
[root@localhost classes]# javac TestingServlet.java
TestingServlet.java:1: package javax.servlet does not exist
import javax.servlet.*;
^
TestingServlet.java:2: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
TestingServlet.java:6: cannot find symbol
symbol: class HttpServlet
public class TestingServlet extends HttpServlet {
^
TestingServlet.java:8: cannot find symbol
symbol : class HttpServletRequest
location: class TestingServlet
public void doGet(HttpServletRequest request,
^
TestingServlet.java:9: cannot find symbol
symbol : class HttpServletResponse
location: class TestingServlet
HttpServletResponse response)
^
TestingServlet.java:10: cannot find symbol
symbol : class ServletException
location: class TestingServlet
throws ServletException, IOException {
^
6 errors

Please help me to overcome this problem

bye
 
Old 03-07-2007, 06:54 PM   #8
kstan
Member
 
Registered: Sep 2004
Location: Malaysia, Johor
Distribution: Dual boot MacOS X/Ubuntu 9.10
Posts: 851

Rep: Reputation: 31
Quote:
Originally Posted by me4linux
TestingServlet.java:1: package javax.servlet does not exist
import javax.servlet.*;
For this error
I guess your servlet jar not inside the jdk library but inside eclipse or tomcat library.

I facing same problem using javac, but it eclipse there is not problem.

Regards,
Ks
 
  


Reply



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
Setting up my java classpath in redhat working2hard Programming 9 07-28-2004 10:15 AM
How to make executetable jar file? if not setting the classpath? antony_csf General 1 07-01-2004 03:11 AM
setting classpath for java in mdk9.2 perryub Linux - Newbie 2 05-07-2004 04:02 PM
setting java classpath... brutal_brad Linux - Newbie 7 09-21-2003 02:52 PM
setting CLASSPATH variable gabadoo Linux - Newbie 7 01-21-2002 04:24 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:42 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration