Moving your java code from Eclipse v.3 to Weblogic Workshop v.8.1
This document describes the steps necessary for moving your java codewritten in Eclipse (or any other similar IDE) to Weblogic Workshop v.8.1.
There are several differences between the styles of handling java files
and this document shows how to overcome them.
In this document I assume that you have already some java code written
and placed in some folder. In our example this folder is called "javasource"
but it can have any name.
Create project, compile and run a standalone module
- Create an application in Workshop,
point it to the root directory of your enterprise application
- Right-click on the application name, select "Import",
select "Java Project" on the right side of the dialog,
browse to the root catalog of your java source,
uncheck "Copy into Application directory", press "Import" button.
Now the project is imported but not compiled. - Right-click on javasource project, select "Properties"
- In "Path" add all jar files that you use for project compilation.
- On default Workshop's build process cleans up the output directory
and recompiles only java files into the output directory.
So if you have *.xml or *.properties files in the source directory
they will disappear in the output directory.
In order to fix it do the following:
In "Build" browse to your output directory in
"Java Project-->Output .class files to".
Next press "Export to Ant file" button at the top in "Build Type".
This will create exported_build.xml file in the root directory
of your java source.
Modify it by adding after <javelin>...</javelin> tag the following:
Save this file. On the project properties window in "Ant Settings" browse to this file and change
<copy todir="${dest.path}" overwrite="true" flatten="false">
<fileset dir="${src.path}">
<exclude name="**/*build*.xml"/>
<exclude name="**/*ant*.xml"/>
<include name="**/*.properties"/>
<include name="**/*.xml"/>
</fileset>
</copy>
"Build Type" to "Use Ant buld". - In "Debugger"
- Direct to your output directory in "Home directory" -
this will allow you to run standalone java applications
(i.e. "main" methods) having this directory as root
so your files can be found. - Add your output directory to the "Application classpath"
- Again add all necessary jar files to the "Application classpath" -
this time it is needed for the run-time environment.
- Direct to your output directory in "Home directory" -
- Press "OK" on "Project Properties" window.
- Select in Main Menu "Build-->Build Project-->javasource"
and verify that the java project is successfully compiled into the output
directory. Verify that your *.xml and *.properties files are also
copied into the output directory. - Verify that standalone applications run in this environment:
- Right-click on "javasource" project and select "Properties"
- In "Create new process settings-->Main class"
enter a name of your class that has "main" method - From the Main Menu select "Debug-->Start":
watch the project rebuilding and outputs from the main method
of your class (if you have System.outs or logger's messages in it)
Compile a Single Java File
On default Workshop cannot compile a single Java file;it can only do builds on a project basis.
The following link of WL Workshop documentation describes
what is needed to be done in order to be able to compile a single Java file.
http://e-docs.bea.com/workshop/docs81/doc/en/workshop/guide/howdoi/howCompileASingleJavaFile.html?skipReload=true
Instruction Notes
- If your .workshop.pref file gets screwed up - do not worry. Simply delete it and restart Workshop.
Workshop will recreate the default version of the file. - Both following entries work fine:
<component name="workshop.workspace.tools.CustomToolAction">
and
<node name="workshop.workspace.tools.CustomToolAction">
Note, that the above document operates with "component"
and if you recreate the pref file, it will have "node". They both work OK. - After you insert <node name="javac"> tag in .workshop.pref file,
save this file and restart the Workshop you will see the following error:
Press "Exit" here and return to .workshop.pref file.
Change the following line
<option name="command" value="compile.cmd "${file.path}"" />
by removing double quotes around ${file.path}. It should look like this now:
<option name="command" value="compile.cmd ${file.path}" />
Save the file, restart Workshop and see that the menu item "javac"
appears under "Tools-->External Tools"
Further Customization
In order for the single file compilation process to be more usablein the team development environment I have done the following changes:
- In .workshop.pref under <node name="javac">
instead of "C:\build_scripts" I put the javasource project home folder
"C:\NMS\2005.1\javasource". - Put compile.cmd in this folder.
Now compile.cmd can be checked in in your source control system. - Modify compile.cmd the following way:
- set PATH=C:\bea\jdk142_05\bin;
If you have later version of JDK don't point
PATH to its "bin" directory; when I tried that,
at run-time I got an error related to versions incompatibility - set CLASSPATH="%CLASSPATH%;[your jars relative paths]"
Notice that double quotes are around entire entry.
[your jars relative paths] can be found in your *.work file:
search for "class.path" string in it and copy the list of jar
relative paths from its value. - Now the compile.cmd file can be checked in your CVS or VSS.
Let's test this now.
- Open a java file, go to "Tools --> External Tools --> javac"
and see that this file compiles to your output directory to the right
place - Open project properties and in "Debugger" area uncheck
"Build before debugging" - this will prevent from building the entire
project every time you start a java standalone file - In the same window specify your java file in
"Create new process settings --> Main class".
Do not type the file extension here. Press OK button. - Make sure that your java file has the "main" method.
Don't forget it has to have the following signature:
public static void main(String[] args) {...} - Press the "Start" button. See your file's main method's output.
Do not forget though that for your next project you will have
to add another entry in your .workshop.pref file and point it
to another directory.
In the future it makes sense to fix the situation when you need
to specify the classpath of all your jars in three places.
It should be somehow centralized.
Congratulations!
You have successfully migrated from Eclipse to Workshop and can nowenjoy the full power of Workshop fast development environment.
No comments:
Post a Comment