I am trying to create my first struts framework in my Tomcat 5.5 container. I keep getting compile errors on my attempt and it seems I dont have something set up correctly in my WEB-INF/lib directory. I copied the struts.jar to my WEB-INF/lib directory and made sure it was in my classpath.
Here is the class file I attemting:
I set up my struts-config.xml file:
The web.xml setup:
My errors message seems to indicate I dont have something set up correctly in my struts?
[ November 22, 2006: Message edited by: Joseph Smithern ]
Putting struts.jar in your WEB-INF/lib directory is a good start. However, you will need not only struts.jar, but all the jar files that came with the download in your WEB-INF/lib directory.
Furthermore, this affects the classpath that will be used by the Application server at runtime, but does nothing to change your compile-time classpath. If you're using an IDE, you will need to find out how to add jar files to your project build path and use that procedure to add the struts.jar file and its dependent jar files.
If you're compiling from the command line, you will need to add the struts.jar as part of the classpath. Example:
[ November 22, 2006: Message edited by: Merrill Higginson ]
Thanks for your reply especially your command line example which is what I am using.
It works but I also had to add my servlet.jar (C:\Program Files\Apache Software Foundation\Tomcat 5.5\common\lib\servlet-api.jar) to the path. Please advise why or if there is a way to set my paths so I dont have to type in this long command:
Before I started this struts work I never had to use the servlet-api.jar in my commands because I had it set in my classpath.
Joined: Feb 15, 2005
One alternative would be to set the CLASSPATH environment variable and then don't specify a classpath at compile time. This way you only have to set it once. Another alternative would be to put the javac command with all the options and parameters in a .bat file and just execute the .bat file.
To be honest with you, I don't know a single professional Java developer who compiles from the command line. It's too cumbersome. All the pros I know compile either from an IDE such as Eclipse or NetBeans, or they compile from an ANT script. If you're serious about Java development, I'd suggest you look into one of these other options.
Joined: Feb 11, 2006
Thanks for the great advise. I set the classpath and it now works great with command line.
I downloaded NetBeans and it seems classpath doesnt work in IDE. I am trying to figure out using the NetBeans Help how to get the classpath to work. One part shows creating explicit classpath and other help says use an ellipsis button which I couldnt find. Any guidance if possible??