This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes compilation command??? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "compilation command???" Watch "compilation command???" New topic
Author

compilation command???

ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830

MyProjects\MyApplication>javac -classpath c:/servlet.jar src/com/my/MyClass.java


What's wrong with this command. I have placed servlet.jar file from tomcat/common/bin to c directory for convenience.

Compiler is not able to recognise request, response and other my custom objects which I am using in this file....

Please help.

Thanks.


[ December 20, 2005: Message edited by: rathi ji ]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

The javac compiler is not going to use your system classpath if you are overriding it with the -classpath switch.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Prabodh Reddy
Greenhorn

Joined: Dec 19, 2005
Posts: 14
u typed sevlet.jar instead of servlet.jar at the command prompt..
pls check it once.
ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
Originally posted by Alimineti Prabodh:
u typed sevlet.jar instead of servlet.jar at the command prompt..
pls check it once.


No, Actually, it just happened here. I am running right command but the same error...

Anybody, please help .

Thanks.




The javac compiler is not going to use your system classpath if you are overriding it with the -classpath switch.


But I don't need any file that is in my classpath for now...

Thanks.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

There is nothing servlet specific about this so moving to Java In General (beginner).
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
If you are working at the command prompt level I recommend Apache Ant.
[ December 20, 2005: Message edited by: Jeff Albrechtsen ]

There is no emoticon for what I am feeling!
badri nath
Ranch Hand

Joined: Dec 21, 2005
Posts: 57
I guess we should add ; at the finish of classpath.
Stuart Ash
Ranch Hand

Joined: Oct 07, 2005
Posts: 637
Try

MyProjects\MyApplication>javac -classpath %classpath%;c:/servlet.jar src/com/my/MyClass.java


ASCII silly question, Get a silly ANSI.
jiju ka
Ranch Hand

Joined: Oct 12, 2004
Posts: 306

Compiler is not able to recognise request, response and other my custom objects which I am using in this file....

HttpServletRequest.class and HttpServletResponse.class should be in servlet.jar.

If "%classpath%" recommended by Stuart Ash is not working, check the contents of servlet.jar

If "ant" is an overkill for what you are doing, keep your classpaths and paths in a .bat file under windows than system variables.

Below is an example of .bat file

File name j.bat
-------------------------------------------------------------
set JAVA_HOME=C:\jdk1.5.0_06
PATH=%PATH%;%JAVA_HOME%\bin;.\source
set CLASSPATH=%CLASSPATH%;.\classes
-------------------------------------------------------------
Then at command prompt you just say
C:\..\source> j


To have your custom classes referenced you will need to specify those folders in classpath.

Below is how my directory structure look like
-------------------------------------------------------------
C:\jiju\java5>dir
Volume in drive C has no label.
Volume Serial Number is 7053-A316

Directory of C:\jiju\java5

12/14/2005 10:55 AM <DIR> .
12/14/2005 10:55 AM <DIR> ..
12/14/2005 11:00 AM <DIR> classes
12/14/2005 11:02 AM 103 j.bat
12/14/2005 10:41 AM <DIR> source
1 File(s) 103 bytes
4 Dir(s) 12,067,139,584 bytes free
-------------------------------------------------------------

When I compile a program I use -d option with javac so that the classes will go to classes folder
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: compilation command???
 
Similar Threads
Basic Doubts
Problem in compiling HelloServlet.java
JSDK2.1: startserver
problem with setting classpath on Win98
problem with javax.servlet.*;