• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Compiling servlet : error no source files

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm reading Head first Servlets and JSP 2nd Edition and I have a problem when I try to compile my servlet class.

Here is my files (I'm actually on the beerV1 folder) :
.
└── beerV1
   ├── classes
   │   └── com
   │       └── example
   │           ├── model
   │           │   └── BeerExpert.class
   │           └── web
   │               └── BeerSelect.class
   ├── etc
   │   └── web.xml
   ├── lib
   ├── src
   │   └── com
   │       └── example
   │           ├── model
   │           │   └── BeerExpert.java
   │           └── web
   │               └── BeerSelect.java
   └── web
       └── form.html

What I have to do :

I'm following these instructions from the book :

cd beerV1
javac -classpath /Users/bert/Applications2/tomcat/common/lib/
servlet-api.jar:classes:. -d classes src/com/example/web/BeerSelect.java



What I've done :

Since I'm on windows, I replaced ":" with ";".
So I did this :

javac -classpath /mnt/c/apache-tomcat-9.0.20/lib/servlet-api.jar;classes;. -d classes src/com/example/web/BeerSelect.java



But the output I get is this :

error: no source files
classes: command not found
-bash: .: -d: invalid option
.: usage: . filename [arguments]



I don't understand this problem because I did exactly what I was asked to do in the book.
 
author & internet detective
Posts: 39343
755
Eclipse IDE VI Editor Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you try it again with the classpath in quotes?

javac -classpath "/mnt/c/apache-tomcat-9.0.20/lib/servlet-api.jar;classes;". -d classes src/com/example/web/BeerSelect.java

Also, is this a valid path in Windows? On my machine the path looks more like c:/apache....
 
Dave Jovi
Greenhorn
Posts: 7
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jeanne Boyarsky wrote:Can you try it again with the classpath in quotes?

javac -classpath "/mnt/c/apache-tomcat-9.0.20/lib/servlet-api.jar;classes;". -d classes src/com/example/web/BeerSelect.java

Also, is this a valid path in Windows? On my machine the path looks more like c:/apache....



Thank you for pointing that it solves my problem... That was my fault I've completely misunderstood when the book said that whe should replace ":" if we are using windows OS. I'm typing on the linux console on windows, so there is no replacement to do.

Everything works perfectly now thank you again.
 
Jeanne Boyarsky
author & internet detective
Posts: 39343
755
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah. So you are using Linux. That makes sense!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!