I'm going through some tutorials and teaching myself some JSP Struts stuff from scratch. I decided to go the classic route and just use whatever Debian Lenny includes in apt so I don't have to worry about new exciting features, just old reliable stuff.
One of the first things you'll need to do with JSP is compile your Class Files to a Java File so it can be properly loaded. You can't run a JAVA file in Tomcat. It just won't work.
I figured since I used apt to install all the goodies it would work perfectly so I tried to compile the first example java file from the tutorial I was following.
So I ran:
javac RegisterAction1.java
I got an error about servlet stuff not found.
import javax.servlet.http.*;
The import javax.servlet cannot be resolved
So I tracked down the servlet stuff jar file and ran:
javac -classpath /usr/share/tomcat5.5/common/lib/servlet-api.jar RegisterAction1.java
It fixed the servlet not found error, but now I got an error about org.apache stuff not found.
import org.apache.struts.action.*;
The import org.apache cannot be resolved
So I tracked down the struts stuff jar file and tried:
javac -classpath /usr/share/tomcat5.5/common/lib/servlet-api.jar:/usr/share/struts1.2/struts.jar RegisterAction1.java
Hooray! It Worked.
I'm not a sucker though, I don't want to have to add all that every time I want to compile a java file relating to Tomcat or Struts though. So in Debian I just go track down and vim my /etc/profile file and add the text:
export CLASSPATH=.:/usr/share/tomcat5.5/common/lib/servlet-api.jar:/usr/share/struts1.2/struts.jar
(Right before the "umask 022")
Now when you log out and log back in, you can run:
javac RegisterAction1.java and it'll work perfectly!
No comments:
Post a Comment