Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

compilation command???

 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The javac compiler is not going to use your system classpath if you are overriding it with the -classpath switch.
 
Prabodh Reddy
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
u typed sevlet.jar instead of servlet.jar at the command prompt..
pls check it once.
 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is nothing servlet specific about this so moving to Java In General (beginner).
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are working at the command prompt level I recommend Apache Ant.
[ December 20, 2005: Message edited by: Jeff Albrechtsen ]
 
badri nath
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess we should add ; at the finish of classpath.
 
Stuart Ash
Ranch Hand
Posts: 637
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try

MyProjects\MyApplication>javac -classpath %classpath%;c:/servlet.jar src/com/my/MyClass.java
 
jiju ka
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic