Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with compiling flag

 
Doru St
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!
I have a problem to compile the source code for a class that is in the book "head first servlets ...", and this problem is generated by the instruction: import com.example.model.*; from the code. How it was said in the book I had a folder tree like (beerV1\classes\com\example\model\) in which is the class that I want to import (BeerExpert.class). The BeerSelect.java file is in beerV1\src\com\example\web\ and I try to compile it, from beerV1 folder how it was write in the book. But I receive the following error: package com.example.model does not exist. I think this may happend because the compiler look in the root folder (beerV1) to find the com folder, but it is in the classes folder. If I try to compile the file being in the classes folder and using the comand:
javac -d D:\Java\Java programs\Head first Servlets and JSP\beerV1\src\com\example\web\BeerSelect.java I recieved the error: invalid flag: programs\Head
Can someone help me in this matter? Thank you!
 
Markas Korotkovas
Greenhorn
Posts: 21
Eclipse IDE Java Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have spaces in your path. D:\Java\Java programs\Head first Servlets and JSP\beerV1\src\com\example\web\BeerSelect.java. Either rename the folders to NOT have the spaces in the name or enclose the path in double quotes "......."
 
Doru St
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I solved finaly the problem by using the comand set CLASSPATH=C:\Program Files\Apache Software Foundation\Tomcat 7.0\lib\servlet-api.jar;classes;.;
and after I compile the code using the comand: javac -d classes src\com\example\web\BeerSelect.java

I don't know why the environment variables didn't work (I put in the variable value the same path, but didn't solve the compile problem), but I'm happy it finaly work!
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you read Markas' post ? -> "enclose the path in double quotes"
 
Doru St
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, but it wasn't necesary for the set CLASSPATH comand. I didn't try it to see if it works. Anyway thank you for the advise, I'll keep in mind!
 
Doru St
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'll try maybe in the week-end when I'll have more time for tests on my classes
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic