10 Replies Latest reply on Apr 9, 2013 7:04 AM by ybxiang.china

    how to compile servlet code ???

    pradhumnjboss

      how to compile servlet code ???

      i use project path:-

       

      shopee

      |_index.jsp

      |_ WEB-INF-classes-servlet.java

       

      i want to compile servlet.java , jdk1.6 can't do that.

      or give me some sites name for online compile & i get class file.

       

       

       

      THANKS 

        • 1. Re: how to compile servlet code ???
          nickarls

          Servlet code is normal java code and is usually compiled in the building process. What build tool are you using and what errors are you seeing?

          If you are new to java, I recommending googling for some general tutorials first.

          • 2. Re: how to compile servlet code ???
            pradhumnjboss

            i used to compile servlet in tomcat .

            but in jboss as 7 as i mentioned above ,i used that way , not eclipse

            so the code gave error  on   importing statement  JAVAX.SERVLET.* ,  HttpServlet (while extending it) & others related to servlet

             

            i compiled this on  jdk1.6/bin.

            • 3. Re: how to compile servlet code ???
              nickarls

              Well, the servlet api has to be available when you compile, no matter how you do it

              • 4. Re: how to compile servlet code ???
                ybxiang.china

                Ant javac compile is easy too:

                 

                 

                <?xml version="1.0" encoding="UTF-8"?>

                <project name="com.ybxiang.nms.manager" default="exportAPI" basedir=".">   

                    <property name="jboss.home" value="D:/java/jboss-as-7.2.0.Final"/>

                    <property name="jboss.conf.dir" value="D:/java/jboss-as-7.2.0.Final/standalone/configuration"/>

                 

                    <property name="war.source.dir" value="${basedir}/ybxiang-forum-war/src"/>

                    <property name="war.classes.dir" value="${basedir}/ybxiang-forum-war/build/classes"/>

                 

                    <property name="ybxiang-forum-ejb-classes" value="${basedir}/ybxiang-forum-ejb/build/classes" />   

                    <property name="jboss-ejb-api_3.1_spec" value="D:/java/jboss-as-7.2.0.Final/modules/system/layers/base/javax/ejb/api/main/jboss-ejb-api_3.1_spec-1.0.2.Final.jar"/>

                    <property name="jboss-jsf-api_2.1_spec" value="D:/java/jboss-as-7.2.0.Final/modules/system/layers/base/javax/faces/api/main/jboss-jsf-api_2.1_spec-2.1.18.Final.jar"/>

                    <property name="jboss-servlet-api_3.0_spec" value="D:/java/jboss-as-7.2.0.Final/modules/system/layers/base/javax/servlet/api/main/jboss-servlet-api_3.0_spec-1.0.2.Final.jar"/>

                 

                    <target name="war.recompile">

                        <delete dir="${war.classes.dir}/com"/>

                        <javac srcdir="${war.source.dir}" destdir="${war.classes.dir}"  >

                            <classpath>

                                <!-- http://ant.apache.org/manual/using.html -->

                                <pathelement location="${ybxiang-forum-ejb-classes}"/>

                                <pathelement location="${jboss-ejb-api_3.1_spec}"/>

                                <pathelement location="${jboss-jsf-api_2.1_spec}"/>

                                <pathelement location="${jboss-servlet-api_3.0_spec}"/>

                            </classpath>

                            <!--

                            <include name="**/*.java"/>

                            <exclude name="**/Example.java"/>

                            -->

                        </javac>

                    </target>

                </project>

                1 of 1 people found this helpful
                • 5. Re: how to compile servlet code ???
                  pradhumnjboss

                  thank you sir.

                  but i also want to see how  build this means <java> tag in build.xml file for servlet

                   

                  THANKS

                  • 6. Re: how to compile servlet code ???
                    ybxiang.china

                    you have too much to learn!

                    • 7. Re: how to compile servlet code ???
                      pradhumnjboss

                      Actually  my platform is Tomcat so can you give me some suggestion how to complite my basics..

                       

                       

                      THANKS.

                      • 8. Re: how to compile servlet code ???
                        nickarls

                        I think what Xiang is trying to say (and actually myself a few posts back) is that perhaps you would need to find some general java/web application tutorials first so that you can ask more specific and relevant questions. This is the forums for JBoss AS and your questions are a bit vague and general. Have you tried http://www.javaranch.com/ ? (it's more professional than the front page might indicate) ;-)

                        • 9. Re: how to compile servlet code ???
                          ybxiang.china

                           

                          Agree with Nicklas.

                          • 10. Re: how to compile servlet code ???
                            ybxiang.china

                            Suggestion:

                             

                            You must know what java is:

                                 Here is the turorial: http://www.avajava.com/tutorials/categories/java-basics

                             

                            (1) Learn how to use IDE(for example, eclipse) to develop web applications at first.

                                 Here is the turorial: http://www.avajava.com/tutorials/categories/eclipse

                             

                            (2) Learn Servlet/JSP/JSF knownedge:

                                 http://www.avajava.com/tutorials/categories/servlets

                                 http://www.avajava.com/tutorials/categories/jsps

                             

                            (3) Study the web container at last:

                                 http://www.avajava.com/tutorials/categories/tomcat

                             

                             

                            If you speak English, maybe job of coding is not suitable for you.

                            If you speak Chinese, there are too many books/web pages discussing java, tomcat, jsp, servlet. Yes, too many!