This discussion is archived
7 Replies Latest reply: Jan 24, 2013 1:20 AM by 986755 RSS

Showing error while compiling the servlet

986755 Newbie
Currently Being Moderated
Hey guys....!

I am a beginner want to compile servlet with following path

javac -classpath \Program Files\Apache Software Foundation\Tomcat 5.5\common\lib\servlet-api.jar;classes:.-d classes src\com\example\web\BeerSelect.java

Problem arises as follows
javac: invalid flag: Files\Apache
Usage: javac <options> <source files>
use -help for a list of possible options

what to do?
where did i make mistake?

Please help me out with this issue...!

Thank you..!

Edited by: 983752 on Jan 23, 2013 12:03 PM
  • 1. Re: Showing error while compiling the servlet
    r035198x Pro
    Currently Being Moderated
    Your path contains spaces e.g \Program Files so you need to wrap the path in quotes e.g "\Program Files\Apache ..." so that it doesn't get broken up when passed to javac
  • 2. Re: Showing error while compiling the servlet
    986755 Newbie
    Currently Being Moderated
    Thanks for your help...

    It worked but i got another problem

    Now, when i compile servlet as follows it shows me error....

    C:\MyProject1\beerV1>javac -classpath "\Program Files\Apache Software Foundation
    \Tomcat 5.5\common\lib\servlet-api.jar";classes:.-d "classes src\com\example\web
    \BeerSelect.java"
    javac: file not found: classes src\com\example\web\BeerSelect.java
    Usage: javac <options> <source files>
    use -help for a list of possible options

    I know that it comes when source file is not present in specified directory but i have this file BeerSelect.java in specified one...! but still i got this problem...!

    Please help me with this one....! Thanks....!
  • 3. Re: Showing error while compiling the servlet
    r035198x Pro
    Currently Being Moderated
    You have -d "classes src\com\example\web\BeerSelect.java"
    so the whole thing is being interpreted as an argument to -d since it's wrapped in quotes. Perhaps you meant -d classes "src\com\example\web\BeerSelect.java"?

    Also you're better off using build tools like maven and IDEs for servlet and other EE related technologies.
  • 4. Re: Showing error while compiling the servlet
    986755 Newbie
    Currently Being Moderated
    Thanks....!

    I did what u said...

    C:\MyProject1\beerV1>javac -classpath "\Program Files\Apache Software Foundation
    \Tomcat 5.5\common\lib\servlet-api.jar";classes:.-d classes "src\com\example\web
    \BeerSelect.java"
    error: Class names, 'classes', are only accepted if annotation processing is exp
    licitly requested
    1 error

    showed me this...!

    I would like to use netbeans but i am a beginner so i want to learn some basic things.....!

    I hope you will help me...!
  • 5. Re: Showing error while compiling the servlet
    r035198x Pro
    Currently Being Moderated
    Ya well if you are a beginner then you should probably start learning by compiling 'by hand' BUT you should not start with learning servlets. Servlets are an application of of the Java language so you need to learn the java language itself first.

    You can learn about using javac here:http://docs.oracle.com/javase/6/docs/technotes/tools/windows/javac.html
  • 6. Re: Showing error while compiling the servlet
    986755 Newbie
    Currently Being Moderated
    Yup thanks...!
  • 7. Re: Showing error while compiling the servlet
    gimbal2 Guru
    Currently Being Moderated
    r035198x wrote:
    Servlets are an application of of the Java language so you need to learn the java language itself first.
    .. and the platform. The tools, the important JDK classes, the workings of the JVM which includes the classpath, jars and packages, classloaders, heap space managment, garbage collector basics, the concept of running software in a virtual machine and what platform independence really means. You're not going to really understand Java web development until you understand many core concepts too; threading and concurrency being of monumental importance. Its of vital importance to know the basic JDK classes too. Date and number formatting/parsing, collections, the concurrency APIs, XML parsing...

    You can't cut corners, you can't learn it from a forum. You need to invest time. Lots and lots of time.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points