Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Cannot compile a file in WindowsXP

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

Can anybody help me in pointing out the problems of the following command line in compiling a file?

javac -classpath "C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\servlet-api.jar":classes:. -d classes "D:\Study\SCWCD Exam\MyProjects\beerV1\src\com\example\web\BeerSelect.java"

In my BeerSelect.java, I have the followings :
package com.example.web;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
......

I have tried to compile this file several times but Compiler always complaint:
package javax.servlet does not exist
package javax.servlet.http does not exist

However, I have checked the servlet-api.jar, it has those two packages.

Thanks for all your help!!

Kenneth
 
Ranch Hand
Posts: 1512
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For the Java compiler to be able to compile Servlets, you need to add the servlet jar files to your Java class path.
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Bosun Bello:
For the Java compiler to be able to compile Servlets, you need to add the servlet jar files to your Java class path.



he did, he just did it wrong.


keeneth, in windows you must use ";" instead of ":" as the separator in the classpath.

try again like this:
javac -classpath "C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\servlet-api.jar";classes;. -d classes "D:\Study\SCWCD Exam\MyProjects\beerV1\src\com\example\web\BeerSelect.java"

also, i would advice against compiling from that path, you'll do better with something like:
"cd \Study\SCWCD Exam\MyProjects\beerV1\" and then "javac -classpath C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\servlet-api.jar;classes;. -d classes src\com\example\web\BeerSelect.java"
 
kenneth See
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear all,

Thanks for your reminder. It works now by using ";" instead of ":".

Kenneth
 
reply
    Bookmark Topic Watch Topic
  • New Topic