Discussions

Web tier: servlets, JSP, Web frameworks: How To Compile the Java Source into Class File in Struts

  1. After I have found information from web.
    I found that Jasper,Jikes, ant are all can be used to compile source.
    But, What they are different?
         Which is better for beginner?
    I have tried to download the jikes and have finished reading the manual. But, I am also confusing about how to use it.
    http://jakarta.apache.org/tomcat/tomcat-4.1-doc/printer/jasper-howto.html#Introduction

    I am trying develop a project in the windows environment now.

    I am look forward to receiving your reply. Thanks

    Threaded Messages (3)

  2. Compiling struts classes[ Go to top ]

    The good news is you can compile struts .java files with any standard java compiler(eg:jikes). But beware, you should have the struts jars as well as your servlet implementation(provided by tomcat or whatever servlet container that you use) jars in your classpath.
    so, you may write a shell script or .bat file to set all required jars in your CLASSPATH. and then invoke "javac" on your sourcefiles.

    But the most elegant, standard and useful way is to use ANT. The following is an eg: ANT build.xml target for compiling struts java files.
       <!-- to compile the java files in web-inf/classes -->
     <target name="compile" depends="prepare" description="to compile java files">
          <path id="classpath">
             <!-- in following directory, there is struts.jar and commons-*.jar-->
             <fileset dir="./web/WEB-INF/lib" includes="*"/>

             <!-- I use weblogic's servlet impl -->
              <fileset dir="${j2ee.dir}" includes="weblogic.jar"/>
           </path>
           <javac srcdir="./web/src"
                  destdir="./web/WEB-INF/classes">
                <classpath refid="classpath"/>
           </javac>
       </target
    This may look a bit confusing to you if you dont know ANT, but it is easy to learn and more easy to use.
  3. Compiling struts classes[ Go to top ]

    Thanks for your help.
    I have another problem again, hope you can help.
    I have tried to use eclipse which having the ant.I can generate the .class already.
    However, there are still some problems which I don't know how to solve.

    This is the printscreen of my situation.
    http://hk.geocities.com/daisy_sina/q.JPG

    Some of the java file still have the problem of "!", but I don't know what it really means.

    Look forward to receving your reply. thanks
  4. Compiling struts classes[ Go to top ]

    sorry, I don't know why the hyperlink is not work.
    But, if you copy and paste the address to a browser, then it will be OK.