Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

compile problem w/ code in HFS book

 
E Weibust
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having a problem getting a number of code examples from the book to compile.

The problem is that I can compile from the Win XP cmd line with:

C:\java\source\hfsj\ch5_beer>javac -classpath c:\java\jakarta-tomcat-5.0.28\common\lib\servlet-api.jar;classes;. -d classes src/com/example/web/*.java

but then when I try to compile from my cygwin cmd line I get a bunch of errors on the javax.servlet/javax.servlet.http packages:

javac -classpath "/home/erikweibust/java/jakarta-tomcat-5.0.28/common/lib/servlet-api.jar" -d classes src/com/example/web/*.java

Any ideas? It's making me nuts because I hate having to Alt-Tab to my XP cmd-line window just to compile.

Thanks...
Erik
 
Kathy Sierra
Cowgirl and Author
Rancher
Posts: 1589
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know the syntax issues for cygwin... is it a bash shell?

Do you need the quotes around that classpath? Do you need to add classes to it? (although that wouldn't fix your servlet API stuff that it's not finding).

There's some cygwin shell stuff at :cygwin shell syntax info (I think)

I hope someone can help with this!

Please let us know what works...

cheers,
Kathy
 
E Weibust
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Kathy. Love the book!

Yes, I'm using bash. No, the quotes aren't necessary. Here are a couple other things I tried:

javac -classpath /home/erikweibust/java/jakarta-tomcat-5.0.28/common/lib/servlet-api.jar -d classes src/com/example/web/*.java

javac -classpath ~/java/jakarta-tomcat-5.0.28/common/lib/servlet-api.jar -d classes src/com/example/web/*.java

Cygwin does some weird things so that it can work and I think they are "messing-up" (that IS a technical term) my javac classpath argument.

Examples:
erikweibust@DALEWEIBUST [/cygdrive/c/cygwin/home] $ ls -dl erikweibust/
drwxrwxrwx+ 15 erikweib Users 0 Sep 24 15:31 erikweibust//

erikweibust@DALEWEIBUST [/cygdrive/c/cygwin/home] $ cd
erikweibust@DALEWEIBUST [~] $ pwd
/home/erikweibust

The above examples show that $HOME is really /cygdrive/cygwin/home, not /home/erikweibust.

I have cut XP cmd-line compiling out of the mix by writing an ant build file, but I still don't like that I can't compile from my cygwin cmd-line.

Thanks for the help...
 
E Weibust
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm still looking for a little help on this.

I'm happy to be using ant, but I still would like to find out why I can't compile from a cygwin cmd-line.

Thanks...
 
Carol Enderlin
drifter
Ranch Hand
Posts: 1364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The link Kathy pointed to indicates that ~ doesn't expand, did you try using $HOME?

oh, the pain of having to alt-tab
 
E Weibust
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yup, I tried $HOME. Still no luck.

This:
javac -classpath $HOME/java/jakarta-tomcat-5.0.28/common/lib/servlet-api.jar -d classes src/com/example/web/*.java

Gets me this:
erikweibust@DALEWEIBUST [~/java/source/hfsj/ch5_beer] $ javac -classpath $HOME/java/jakarta-tomcat-5.0.28/common/lib/servlet-api.jar -d classes src/com/example/web/*.java
src/com/example/web/BeerSelect.java:3: package javax.servlet does not exist
import javax.servlet.*;
^
src/com/example/web/BeerSelect.java:4: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
src/com/example/web/BeerSelect.java:7: package com.example.model does not exist
import com.example.model.BeerExpert;
^
src/com/example/web/BeerSelect.java:12: cannot resolve symbol
symbol : class HttpServlet
location: class com.example.web.BeerSelect
public class BeerSelect extends HttpServlet {

....

src/com/example/web/TestInitParams.java:29: cannot resolve symbol
symbol : method getServletConfig ()
location: class com.example.web.TestInitParams
out.println( "admin email is " + getServletConfig().getInitParameter(
^
19 errors
 
Kai Witte
Ranch Hand
Posts: 356
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,

it totally depends on wether you use a Java-compiler for windows or a compiler that is specially made for cygwin / compiled under cygwin!

Here are the things that you have to consider when you try use the windows-JDK within cygwin:

  • Think about what THE COMPILER wants to see. The compiler is for windows, so it wants something like: javac -classpath c:\mylib.jar;. Hello.java
  • Think about the way the bash pre-processes things before it gives them to the compiler. In this example you have to escape the "\" and the ";": javac -classpath c:\\mylib.jar\;. Hello.java
  • To test your solution (find out what the compiler really gets) do echo [yourcommand], in this case: "echo javac -classpath c:\\mylib.jar\;. Hello. java".



  • Conan
    [ October 04, 2004: Message edited by: Conan Elvitaro ]
     
    E Weibust
    Ranch Hand
    Posts: 54
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks to everyone, especially Conan.

    The solution was simple. Put my classpath in quotes and type it as if it was a list of windows style paths.

    erikweibust@DALEWEIBUST [~/java/source/hfsj/ch5_beer] $ javac -classpath "c:\java\jakarta-tomcat-5.0.28\common\lib\servlet-api.jar;classes;." -d classes src/com/example/web/*.java

    I hope that helps someone else later.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic