jmitchell 2002/11/24 21:25:15 Modified: doc/faqs index.xml netbeans.xml project.xml Added: doc/faqs eclipse.xml Log: Adding a few docs for basic setup of Netbeans and Eclipse. (Will be adding more later) Revision Changes Path 1.3 +2 -0 jakarta-struts/doc/faqs/index.xml Index: index.xml =================================================================== RCS file: /home/cvs/jakarta-struts/doc/faqs/index.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- index.xml 6 Nov 2002 22:48:46 -0000 1.2 +++ index.xml 25 Nov 2002 05:25:14 -0000 1.3 @@ -16,6 +16,8 @@ <ul> <li><a href="ssl.html">SSL Howto</a></li> + <li><a href="eclipse.html">Example development environment with Eclipse 2.0.1</a></li> + <li><a href="netbeans.html">Example development environment with Netbeans 3.4</a></li> </ul> </section> 1.2 +214 -105 jakarta-struts/doc/faqs/netbeans.xml Index: netbeans.xml =================================================================== RCS file: /home/cvs/jakarta-struts/doc/faqs/netbeans.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- netbeans.xml 22 Nov 2002 02:45:22 -0000 1.1 +++ netbeans.xml 25 Nov 2002 05:25:14 -0000 1.2 @@ -6,119 +6,228 @@ <author>James Mitchell</author> -<title>How to setup struts in Netbeans IDE - Apache Struts</title> +<title>How to setup a basic Struts project using Netbeans IDE - Apache Struts</title> </properties> <body> -<chapter href="netbeans" name="How to setup struts in Netbeans IDE"> - -<section name="For working on the distribution itself"> -<ol> -<li> - Create a new project (from the Project Manager window) -</li> -<li> - Download the struts source distribution (or use built-in cvs to get - the module) -</li> -<li> - Extract to a local drive (if on windoze, try not to have spaces in - the directory (such as C:\My Documents) -</li> -<li> - Mount the directory you unzipped to -</li> -<li> - Copy build.properties.sample to build.properties and customize to point - to where you keep those jars -</li> -<li> - Mount each of the source directories that you wish to work in - For me, I use:<br /> - <code> - jakarta-struts/src/share<br /> - jakarta-struts/src/example - </code> -</li> -<li> - Mount each jar referenced in the build.properties file<br /> - <b>Note</b> - NetBeans has built in support for auto-mounting these if your - build.xml specifies the jars in the project.classpath, but - that's not the case for the default struts distribution. -</li> -</ol> +<chapter href="netbeans" name="How to setup a basic Struts project using Netbeans IDE"> +<section name="Legal Disclamer"> + +Please read <a href="http://jakarta.apache.org/site/idedevelopers.html">this</a> first.<br/> +<p> +* DISCLAIMER - This simple How-To shows you one of many ways to setup a working project using<br/> +the Struts framewoek. This is mainly geared toward struts users who are new to Netbeans, and<br/> +don't want to spend a lot of time figuring out the differences between their old IDE (if any)<br/> +and this one.<br/> +<br/> +I will also apologize ahead of time for the formatting of this page.<br/> +</p> +<br/> +In this How-To, I will demonstrate (using Netbeans 3.4) how to setup, compile, and build +a customized version of the struts-example.<br/> </section> - -<section name="For doing your own thing"> + + +<section name="Let's get started"> <ol> -<li> - Create a new project (from the Project Manager window) -</li> -<li> - Download (or build for yourself) the required jars<br /> - (See the jakarta-struts-1.1-b2/webapps/struts-example.war) -</li> -<li> - Create a directory (I use a structure similar to how the webapp will exist) -<pre> - +-/my-project - | - +-/WEB-INF - | - +-/classes - | - +-/lib - | - +-/src</pre> -</li> -<li> - Create a build.xml for your project (so ant can build and war it for you). - I recommend you use an existing file to get a jump start on development. - Actually, I recommend you re-use someone's entire existing project. That - will surely get you ahead of the game. -</li> -<li> - Mount that directory<br /> - <i>If you specified the build classpath and the jars are there, NetBeans - will mount the jars for you automatically.</i> -</li> -<li> - Mount each of the source directories that you wish to work in - /myproject/WEB-INF/src -</li> -<li> - Always work in the node in #6 when modifying your java files. -</li> + <li> + Create a new project.<br/> + <img src="../images/how-to/netbeans/creating-project3.jpg"></img><br/><br/><br/> + <img src="../images/how-to/netbeans/creating-project4.jpg"></img><br/><br/><br/> + <img src="../images/how-to/netbeans/creating-project5.jpg"></img><br/><br/><br/> + <img src="../images/how-to/netbeans/creating-project6.jpg"></img><br/><br/><br/> + <img src="../images/how-to/netbeans/creating-project8.jpg"></img><br/><br/><br/> + </li> + <li> + Now let's create (or reuse) a directory to hold the project. + What I did was copy the struts-example.war from the Struts distribution + and extracted it (using Winzip) like this: + <br/> + <img src="../images/how-to/netbeans/directory.jpg"></img><br/><br/><br/> + </li> + <li> + Next we need to create a build.xml to build our project. This file will sit in the root<br/> + directory of your project. (Actually, it doesn't matter where sits so long as you make <br/> + the appropriate changes to directories and such.)<br/> + <br/> + *Note - I will not spend any time here trying to convice you why you should be <br/> + using Ant to build your projects. I guess I consider this to be obvious.<br/> + Here is the build.xml file I use for this demonstration (you MUST modify this <br/> + to use your environment):<br/> + <pre> + + <project name="Struts Example" default="main" basedir="."> + + <!-- This is a basic build script, only the minimums here --> + + <!-- Tell ant to use my environment variables --> + <property environment="env"/> + + <property file="./build.properties"/> + + <property name="build.compiler" value="modern"/> + <property name="build.dir" value="./WEB-INF/classes" /> + <property name="src.dir" value="./WEB-INF/src"/> + <property name="servlet.jar" value="/Apache_Home/jakarta-servletapi-4/lib/servlet.jar"/> + <property name="war.file" value="struts-example"/> + <property name="war.file.name" value="${war.file}.war"/> + <property name="tomcat.home" value="${env.CATALINA_HOME}"/> + <property name="deploy.dir" value="${tomcat.home}/webapps"/> + + <path id="project.class.path"> + <fileset dir="./WEB-INF/lib/"> + <include name="**/*.jar"/> + </fileset> + <pathelement path="${src.dir}"/> + <pathelement path="${servlet.jar}"/> + </path> + + <target name="clean"> + <delete dir="${build.dir}" includeEmptyDirs="true" /> + </target> + + + <target name="prep"> + <mkdir dir="${build.dir}"/> + </target> + + <target name="compile"> + <javac srcdir="${src.dir}" + destdir="${build.dir}" + debug="on" + deprecation="on"> + <include name="**/*.java"/> + <classpath refid="project.class.path"/> + </javac> + </target> + + <target name="cleanWebApp"> + <delete file="${deploy.dir}/${war.file.name}" /> + <delete dir="${deploy.dir}/${war.file}" includeEmptyDirs="true" /> + </target> + + <target name="war"> + <war warfile="${war.file.name}" webxml="./WEB-INF/web.xml"> + <fileset dir="./" includes="**/*.*" excludes="*.war, **/*.nbattrs, web.xml, **/WEB-INF/**/*.*, **/project-files/**/*.*"/> + <webinf dir="./WEB-INF" includes="**/*" excludes="web.xml, **/*.jar, **/*.class"/> + <lib dir="./WEB-INF/lib"/> + <classes dir="${build.dir}" includes="**/*.properties" /> + </war> + </target> + + <target name="deploy"> + <copy todir="${deploy.dir}"> + <fileset dir="./" includes="${war.file.name}"/> + </copy> + </target> + + <target name="main" depends="clean, prep, cleanWebApp, compile, war"/> + + </project> + + </pre> + </li> + <li> + Build the project using Ant from the command line.<br/> + Here's what I get: + + <pre> + + C:\personal\development\Projects\struts-examples\struts-example>ant + Buildfile: build.xml + + clean: + [delete] Deleting directory C:\personal\development\Projects\struts-examples\struts-example\WEB-INF\classes + + prep: + [mkdir] Created dir: C:\personal\development\Projects\struts-examples\struts-example\WEB-INF\classes + + cleanWebApp: + [delete] Deleting: C:\Apache_Home\jakarta-tomcat-4.0.6\webapps\struts-example.war + [delete] Deleting directory C:\Apache_Home\jakarta-tomcat-4.0.6\webapps\struts-example + + compile: + [javac] Compiling 22 source files to C:\personal\development\Projects\struts-examples\struts-example\WEB-INF\classes + [javac] C:\personal\development\Projects\struts-examples\struts-example\WEB-INF\src\org\apache\struts\webapp\example\memory\MemoryDatabasePlugIn.java:78: warning: org.apache.struts.config.ApplicationConfig in org.apache.struts.config has been deprecated + [javac] import org.apache.struts.config.ApplicationConfig; + [javac] ^ + [javac] C:\personal\development\Projects\struts-examples\struts-example\WEB-INF\src\org\apache\struts\webapp\example\memory\MemoryDatabasePlugIn.java:185: warning: org.apache.struts.config.ApplicationConfig in org.apache.struts.config has been deprecated + [javac] public void init(ActionServlet servlet, ApplicationConfig config) + [javac] ^ + [javac] C:\personal\development\Projects\struts-examples\struts-example\WEB-INF\src\org\apache\struts\webapp\example\memory\MemoryDatabasePlugIn.java:185: warning: init(org.apache.struts.action.ActionServlet,org.apache.struts.config.ApplicationConfig) in org.apache.struts.action.PlugIn has been deprecated + [javac] public void init(ActionServlet servlet, ApplicationConfig config) + [javac] ^ + [javac] C:\personal\development\Projects\struts-examples\struts-example\WEB-INF\src\org\apache\struts\webapp\example\memory\MemoryDatabasePlugIn.java:185: warning: org.apache.struts.config.ApplicationConfig in org.apache.struts.config has been deprecated + [javac] public void init(ActionServlet servlet, ApplicationConfig config) + [javac] ^ + [javac] 4 warnings + + war: + [war] Building war: C:\personal\development\Projects\struts-examples\struts-example\struts-example.war + + main: + + BUILD SUCCESSFUL +Total time: 11 seconds + </pre> + <br/> + </li> + <li> + If it did not build for you, verify that the external jars (external to this project) are + specified correctly.<br/> + </li> + <li> + Now we can finish seting up our Netbeans project<br/><br/> + Mount the directory where we extracted the example and where we ran the build:<br/> + <img src="../images/how-to/netbeans/building1.jpg"></img><br/><br/><br/> + <img src="../images/how-to/netbeans/building2.jpg"></img><br/><br/><br/> + </li> + <li> + If specified correctly, Netbeans will parse the build.xml automatically and will use <br/> + (mount jars) the resources that you've declared for building.<br/> + <img src="../images/how-to/netbeans/building3.jpg"></img><br/><br/><br/> + </li> + <li> + I usually get rid of the additional mounted directory under /WEB-INF/classes. <br/> + Since everthing there gets overwritten with each build, I don't usually need to<br/> + see this (or possibly make changes in the wrong place)<br/> + <img src="../images/how-to/netbeans/building4.jpg"></img><br/><br/><br/> + </li> + <li> + In order for Netbeans to understand the package structure for our source code, we need<br/> + to mount all source directories directly. <br/><br/> + *Note - Some IDEs will do this automatically <br/> + (Eclipse) or can be configured from the project config file (JBuilder)<br/> + <img src="../images/how-to/netbeans/building5.jpg"></img><br/><br/><br/> + <img src="../images/how-to/netbeans/building6.jpg"></img><br/><br/><br/> + </li> + <li> + Use your source mount point to add/edit/delete your .java files<br/> + <img src="../images/how-to/netbeans/building7.jpg"></img><br/><br/><br/> + </li> + <li> + Using the initial mount point, expand until you can right-click on the build.xml file (or one<br/> + of the targets) and build the project<br/> + <img src="../images/how-to/netbeans/building8.jpg"></img><br/><br/><br/> + </li> + <li> + If you receive errors from Netbeans (choking on the XML parse), don't worry, I did too.<br/> + I always call ant on the command line anyway, so I don't worry too much about the IDE's <br/> + internal XML jars.<br/> + <!--[:TODO:] finish this section with solution to Netbeans ant/xml incompatibility woes--><br/> + <img src="../images/how-to/netbeans/building8.jpg"></img><br/><br/><br/> + </li> + <li> + Feel free to change the code as you like, and then build and deploy your new app. + </li> + </ol> -<p> -I'll also take this opportunity to tell you that I recommend using Eclipse. I -was a NetBeans advocate for the longest time, but a few weeks ago several -discussion had prompted me to try out Eclipse, and I can say without a doubt, -that it is much more mature an IDE than NetBeans. And since they are both Open -Source.....hey....why not? -</p> -<p> -One definite advantage Eclipse has over NetBeans is that Eclipse is built using -SWT (Standard Widget Toolkit). That means that the IDE is written in Java, but -the underlying framework uses native JNDI calls the OS API.....or, in other -words......"its fast as Hell on windows". -</p> -<p> -Anyone who has left NetBeans running in the background overnight on a laptop -knows the pain of doing an Alt+Tab back to the IDE and seeing how Swing pulls -its rather large A## up from the swap file....heh heh :) -</p> -<p> -Hope that will help you get started. I was planning to post a how-to for doing -this and a few other tasks with NetBeans, Eclipse, and JBuilder. I even have -quite a few screenshots taken, but I just haven't finished it. -</p> -<p> -Good Luck with it!!! -</p> </section> -</chapter></body></document> + +</chapter> +</body> +</document> 1.5 +2 -1 jakarta-struts/doc/faqs/project.xml Index: project.xml =================================================================== RCS file: /home/cvs/jakarta-struts/doc/faqs/project.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- project.xml 22 Nov 2002 02:45:22 -0000 1.4 +++ project.xml 25 Nov 2002 05:25:14 -0000 1.5 @@ -12,8 +12,9 @@ </menu> <menu name="Howtos"> - <item href="netbeans.html" name="Netbeans"/> <item href="ssl.html" name="SSL"/> + <item href="netbeans.html" name="Netbeans"/> + <item href="eclipse.html" name="Eclipse"/> </menu> <menu name="Struts"> 1.1 jakarta-struts/doc/faqs/eclipse.xml Index: eclipse.xml =================================================================== <?xml version="1.0"?> <document url="./ssl.xml"> <properties> <author>James Mitchell</author> <title>How to setup a basic Struts project using Eclipse IDE - Apache Struts</title> </properties> <body> <chapter href="eclipse" name="How to setup a basic Struts project using Eclipse IDE"> <section name="Legal Disclamer"> <p> * DISCLAIMER - This simple How-To shows you one of many ways to setup a working project using<br/> the Struts framewoek. This is mainly geared toward struts users who are new to Eclipse, and<br/> don't want to spend a lot of time figuring out the differences between their old IDE (if any)<br/> and this one.<br/> <br/> I will also apologize ahead of time for the formatting of this page.<br/> </p> <br/> In this How-To, I will demonstrate (using Eclipse 2.0.1) how to setup, compile, run,<br/> and debug the struts-example web application that is bundled with the distribution.<br/> Next, I will modify the code to pull some data from a MySql database using the popular <br/> relational mapping tool OJB. (This is actually quite simple) </section> <section name="Let's get started"> Before we begin, you will need to create a directory somewhere to store your project.<br/> I typically use C:\personal\development\Projects\(some project)<br/> Once that's done, extract the struts-example.war to that directory <br/> (using your favorite zip utility)<br/> <br/> Delete the META-INF folder because this will be created during the build/jar/war process.<br/> Add a build.xml file to the project root. I use something like this: <pre> <project name="Struts Example" default="main" basedir="."> <!-- This is a basic build script, only the minimums here --> <!-- Tell ant to use my environment variables --> <property environment="env"/> <property file="./build.properties"/> <property name="build.compiler" value="modern"/> <property name="build.dir" value="./WEB-INF/classes" /> <property name="src.dir" value="./WEB-INF/src"/> <property name="servlet.jar" value="/Apache_Home/jakarta-servletapi-4/lib/servlet.jar"/> <property name="war.file" value="struts-example"/> <property name="war.file.name" value="${war.file}.war"/> <property name="tomcat.home" value="${env.CATALINA_HOME}"/> <property name="deploy.dir" value="${tomcat.home}/webapps"/> <path id="project.class.path"> <fileset dir="./WEB-INF/lib/"> <include name="**/*.jar"/> </fileset> <pathelement path="${src.dir}"/> <pathelement path="${servlet.jar}"/> </path> <target name="clean"> <delete dir="${build.dir}" includeEmptyDirs="true" /> </target> <target name="prep"> <mkdir dir="${build.dir}"/> </target> <target name="compile"> <javac srcdir="${src.dir}" destdir="${build.dir}" debug="on" deprecation="on"> <include name="**/*.java"/> <classpath refid="project.class.path"/> </javac> </target> <target name="cleanWebApp"> <delete file="${deploy.dir}/${war.file.name}" /> <delete dir="${deploy.dir}/${war.file}" includeEmptyDirs="true" /> </target> <target name="war"> <war warfile="${war.file.name}" webxml="./WEB-INF/web.xml"> <fileset dir="./" includes="**/*.*" excludes="*.war, **/*.nbattrs, web.xml, **/WEB-INF/**/*.*, **/project-files/**/*.*"/> <webinf dir="./WEB-INF" includes="**/*" excludes="web.xml, **/*.jar, **/*.class"/> <lib dir="./WEB-INF/lib"/> <classes dir="${build.dir}" includes="**/*.properties" /> </war> </target> <target name="deploy"> <copy todir="${deploy.dir}"> <fileset dir="./" includes="${war.file.name}"/> </copy> </target> <target name="main" depends="clean, prep, cleanWebApp, compile, war"/> </project> </pre> <ol> <li> Create a new project.<br/> <img src="../images/how-to/eclipse/developing-eclipse-style01.jpg"></img><br/><br/><br/> </li> <li> New Java Project<br/> <img src="../images/how-to/eclipse/developing-eclipse-style02.jpg"></img><br/><br/><br/> </li> <li> Browse for the folder you created for your project.<br/> <img src="../images/how-to/eclipse/developing-eclipse-style03.jpg"></img><br/><br/><br/> <img src="../images/how-to/eclipse/developing-eclipse-style04.jpg"></img><br/><br/><br/> </li> <li> Eclipse will detect your source folders from any subdirectories under your project.<br/> <img src="../images/how-to/eclipse/developing-eclipse-style05.jpg"></img><br/><br/><br/> </li> <li> In our case, this is where the src folder was placed.<br/> <img src="../images/how-to/eclipse/developing-eclipse-style06.jpg"></img><br/><br/><br/> </li> <li> Default standard libs are automatically added depending on the type of project.<br/> <img src="../images/how-to/eclipse/developing-eclipse-style07.jpg"></img><br/><br/><br/> </li> <li> Add the existing web app jars.<br/> <img src="../images/how-to/eclipse/developing-eclipse-style08.jpg"></img><br/><br/><br/> </li> <li> Now we need to add a few jars from the file system.<br/> <img src="../images/how-to/eclipse/developing-eclipse-style09.jpg"></img><br/><br/><br/> </li> <li> We always need this one (servlet.jar)<br/> <img src="../images/how-to/eclipse/developing-eclipse-style10.jpg"></img><br/><br/><br/> </li> <li> Ahhhh...everything looks ok for now. You can always go back and modify these settings <br/> later.<br/> <img src="../images/how-to/eclipse/developing-eclipse-style11.jpg"></img><br/><br/><br/> <img src="../images/how-to/eclipse/developing-eclipse-style12.jpg"></img><br/><br/><br/> </li> <li> When everything settles down, you should see something like this (of course, it might look different depending on your installation/customization):<br/> <img src="../images/how-to/eclipse/developing-eclipse-style13.jpg"></img><br/><br/><br/> </li> <li> Compilation warnings and errors are detected immediately. In this screenshot, I drill down<br/> into the source folder, package, file, class, and double click on the method....which <br/> brings up the source editor. I hover the mouse over the affending warning to see <br/> a description of what' wrong.<br/> <img src="../images/how-to/eclipse/developing-eclipse-style14.jpg"></img><br/><br/><br/> </li> <li> I changed ApplicationConfig to ModuleConfig, then saved and now I see new errors.<br/> You can right click and import ModuleConfig right from the error.<br/> <img src="../images/how-to/eclipse/developing-eclipse-style15.jpg"></img><br/><br/><br/> </li> <li> A quick look at the import section.<br/> <img src="../images/how-to/eclipse/developing-eclipse-style18.jpg"></img><br/><br/><br/> </li> <li> Right click, Source, Organize Imports<br/> <img src="../images/how-to/eclipse/developing-eclipse-style20.jpg"></img><br/><br/><br/> </li> <li> Ahhhh...better<br/> <img src="../images/how-to/eclipse/developing-eclipse-style21.jpg"></img><br/><br/><br/> </li> <li> From the Package Explorer, right click your build.xml and run Ant:<br/> <img src="../images/how-to/eclipse/developing-eclipse-style22.jpg"></img><br/><br/><br/> </li> <li> Is this cool or what?<br/> <img src="../images/how-to/eclipse/developing-eclipse-style23.jpg"></img><br/><br/><br/> </li> <li> Oh crap!<br/> <img src="../images/how-to/eclipse/developing-eclipse-style24.jpg"></img><br/><br/><br/> </li> <li> Quick look at what jars are being used to process my build.<br/> <img src="../images/how-to/eclipse/developing-eclipse-style26.jpg"></img><br/><br/><br/> <img src="../images/how-to/eclipse/developing-eclipse-style25.jpg"></img><br/><br/><br/> </li> <li> I simply removed all the existing jars from the IDE's Ant configuration and<br/> added all from my own installation.<br/> <img src="../images/how-to/eclipse/developing-eclipse-style27.jpg"></img><br/><br/><br/> </li> <li> Cant't forget that last one<br/> <img src="../images/how-to/eclipse/developing-eclipse-style28.jpg"></img><br/><br/><br/> </li> <li> Everything went ok (for me)<br/> <img src="../images/how-to/eclipse/developing-eclipse-style30.jpg"></img><br/><br/><br/> <img src="../images/how-to/eclipse/developing-eclipse-style29.jpg"></img><br/><br/><br/> <img src="../images/how-to/eclipse/developing-eclipse-style31.jpg"></img><br/><br/><br/> </li> <li> Time to test-drive<br/> <img src="../images/how-to/eclipse/developing-eclipse-style32.jpg"></img><br/><br/><br/> </li> </ol> </section> </chapter></body></document>
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>