Wednesday, December 29, 2010

ANT - sample build.xml & build.properties files for creating WAR

build.xml

<?xml version="1.0" ?>
<project name="TestProject" default="war" basedir=".">

<property file="build.properties"/>

<property name="src.home" value="${basedir}/src"></property>
<property name="dist.home" value="${basedir}/dist"/>
<property name="web.home" value="${basedir}/WebRoot"></property>
<property name="build.home" value="${web.home}/WEB-INF/classes"/>
<property name="lib.home" value="${web.home}/WEB-INF/lib"/>
<property name="lib.ext.home" value="${basedir}/lib"/>


<path id="compile.classpath">
<fileset dir="${lib.home}">
<include name="*.jar"/>
</fileset>
<fileset dir="${lib.ext.home}">
<include name="*.jar"/>
</fileset>
</path>

<target name="init">
<mkdir dir="${dist.home}" />
</target>

<target name="compile" depends="init" >
<javac destdir="${build.home}" debug="true" srcdir="${src.home}">
<classpath refid="compile.classpath"/>
</javac>
<copy todir="${build.home}">
<fileset dir="${src.home}" includes="**/*.properties,**/*.xml"/>
</copy>
</target>

<target name="war" depends="compile">
<war destfile="${dist.home}/${app.name}.war" webxml="${web.home}/WEB-INF/web.xml">
<fileset dir="${web.home}"/>
</war>
</target>

<target name="clean">
<delete dir="${dist.home}" />
<delete includeemptydirs="true">
<fileset dir="${build.home}" includes="**/*"/>
</delete>
</target>

<target name="deploy2Tomcat">
<copy todir="${tomcat.webapps.dir}">
<fileset dir="${dist.home}" includes="${app.name}.war" />
</copy>
</target>

</project>

<copy todir="${build.home}">
<fileset dir="${src.home}" includes="**/*.properties,**/*.xml"/>
</copy>
</target>

<target name="war" depends="compile">
<war destfile="${dist.home}/${app.name}.war" webxml="${web.home}/WEB-INF/web.xml">
<fileset dir="${web.home}"/>
</war>
</target>

<target name="clean">
<delete dir="${dist.home}" />
<delete includeemptydirs="true">
<fileset dir="${build.home}" includes="**/*"/>
</delete>
</target>

<target name="deploy2Tomcat">
<copy todir="${tomcat.webapps.dir}">
<fileset dir="${dist.home}" includes="${app.name}.war" />
</copy>
</target>

</project>


build.properties

app.name=TestProject

catalina.home=D:/apache-tomcat-6.0.20
tomcat.webapps.dir=${catalina.home}/webapps

Tuesday, September 07, 2010

Macintosh - Run jar files by double clicking

Macintosh - Run jar files by double clicking

This page assumes you want to run a .jar file directly, on your Macintosh, without splitting it up in any way.
First you have to have the "MRJ", the Macintosh Java Runtime. Then you have to find "JBindery".

In the Command Menu, where it says Class, you enter the name of the main program. For example, "jdrill", "CFclient", or some other classname.

Then pull down the 'ClassPath' submenu, click on 'Add .zip file', and select the .jar file you want. Then click "Run".

You can create an application by selecting the 'FILE' menu, then 'Save As...'. Once you've done that, you can double click on the icon to execute the java crossfire client.

Saturday, July 31, 2010

Command Prompt option on Right Click Menu

How to add command prompt option to right click ?

Most of us often need to open the command prompt which opens at User's Home directory and we had to change the path manually every time we open the command prompt. 

For making this much easier, I am providing here a simple way which you will be glad to use instead of irritating/time consuming way.

With below steps, you can open the command prompt and find yourself at the location you want to reach with just a single click of mouse.

[1] Create a new file and save it with any name but with the extension ".reg" i.e. registry file extension.

filename ezample:= abc.reg

[2] Now copy paste below code inside that file and again save it.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\Command]
@="Command Prompt"

[HKEY_CLASSES_ROOT\Directory\shell\Command\Command]

@="cmd.exe /k cd %1"

[3] Execute this file by simply double-clicking over it.

[4] Command Prompt option is added whenever you do a right-click on a folder.

This is one time procedure.

[5] Now onwards whenever you want to open the command prompt and reach out to a particular location, you can just browse through windows file explorer and right click on that particular folder and select command prompt option. 


Friday, July 30, 2010

Eclipse - Debug Web Application running on Tomcat/JBoss

How to debug a web application, running on Tomcat/JBoss server, in Eclipse ?

Here are the simple steps to follow:

Tomcat

[1] create new batch file along side "catalina.bat" file, paste following code, save and run:

set JPDA_ADDRESS=8000
set JPDA_TRANSPORT=dt_socket
catalina.bat jpda start

[2] Start eclipse -> Run menu -> debug configuration -> Remote Java Application -> New launch configuration -> Make sure port is 8000 in connection properties.



JBoss

[1] Edit the run.bat file of JBoss to use the following debug options (note the suspend=n option, this tells the server not to wait till the debugger attaches itself to the server

set JAVA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n %JAVA_OPTS%

2) Start the server from the command line, using the run.bat file.

3) Once the server has completely started, i go to my (plain) Eclipse project and create a new "Remote Java Application" debug session (if it's not already created). In the "Port" text box i specify 8787 (the same as what i have in the run.bat). Then click on Debug.

The steps will be the same for NetBeans too (expect for the part where you have to configure NetBeans to listen to the debug port).