# How Do I: Compile a Single Java File?

To selectively compile a single JAVA file, you can integrate a custom compilation script into the Workshop IDE by declaring the custom script as an "external tool". You can then pass single JAVA files from the IDE to the custom script.

## Declaring a Custom Compilation Script as an "External Tool"

1. On Windows operating systems, open the the Workshop Preferences file located at C:\Documents and Settings\[Windows_user_name]\.workshop.pref.
2. Edit the element <component name="workshop.workspace.tools.CustomToolAction"> to include your custom compilation script. This element determines the options that appear in the menu bar Tools-->External Tools.

           <component name="workshop.workspace.tools.CustomToolAction">
             <node name="javac">
               <option name="capture" value="true" />
               <option name="command" value="compile.cmd  "${file.path}"" />
               <option name="directory" value="C:\build_scripts" />
               <option name="interactive" value="false" />
             </node>
           </component>

   The element <node name="javac"> causes a menu option named "javac" to appear on the menu bar Tools-->External Tools.
   The element <option name="directory" value="C:\build_scripts" /> tells Workshop where to look for your build script (you can place the build script in any local directory).
   The element <option name="command" value="compile.cmd" "${file.path}" /> tells Workshop to pass the currently open file to the build script.

## Place the Custom Compilation Script in the Appropriate Directory

- Save your build script in the directory specified in the element <option name="directory" value="C:\build_scripts" />. Below is a build script that you can use as a template.
  compile.cmd

          set PATH=D:\jdk1.4.2_04\bin;

          set CLASSPATH=MyClasses

          set CLASS_DIR=C:\bea\weblogic81\samples\workshop\SamplesApp\WebApp\WEB-INF\classes

          javac -d %CLASS_DIR% -classpath %CLASSPATH% %1

          echo compiled %1

          popd

To compile a JAVA file, open the file in the Workshop IDE, and select Tools-->External Tools-->javac. The compile results will be displayed on the javac tab.

Related Topics

How Do I: Use a Custom Ant Build for a Project?

How Do I: Call wlwBuild.cmd from an ANT build.xml file?

wlwBuild Command

Apache Ant 1.5.4 Manual