aspose file tools*
The moose likes Beginning Java and the fly likes Problem with compiling flag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Problem with compiling flag" Watch "Problem with compiling flag" New topic
Author

Problem with compiling flag

Doru St
Greenhorn

Joined: Feb 16, 2011
Posts: 4
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

Joined: Jan 27, 2011
Posts: 21

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

Joined: Feb 16, 2011
Posts: 4
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

Joined: Nov 24, 2005
Posts: 14688
    
  16

Did you read Markas' post ? -> "enclose the path in double quotes"


[My Blog]
All roads lead to JavaRanch
Doru St
Greenhorn

Joined: Feb 16, 2011
Posts: 4
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

Joined: Feb 16, 2011
Posts: 4
I'll try maybe in the week-end when I'll have more time for tests on my classes
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Problem with compiling flag