Monday, April 28, 2008

J-Link: Compile Your Pro/ENGINEER Java Application with Intralink!

If you've wanted to try some Pro/ENGINEER programming using J-Link (the free Java API), but didn't know how to compile your program, then this article is for you. Forget Netbeans, forget Eclipse, and forget downloading and installing the JDK. Just use Intralink's Java Runtime Environment to compile your apps.

Seriously though, those IDE's are really great programs, but sometimes you can't install them, or they're not available on your system, or you just need something minimal and fast. Fortunately, Intralink contains everything we need to compile J-Link applications: a JRE and tools.jar. tools.jar is the codebase from Javasoft that contains Java compilation code.

Here is a batch file that will compile J-Link Java code on Windows:

@echo off
rem jlink_javac.bat - Compile JLink Apps using Intralink JDK

set Proe_Install_Dir=c:\ptc\proeWildfire2.0_m200
set IL_Install_Dir=c:\ptc\proiclient3.3_m021
set CLASSPATH=%IL_Install_Dir%\i486_nt\lib\tools.jar
set path=%IL_Install_Dir%\i486_nt\jre\bin;%path%

java -classpath %Proe_Install_Dir%\text\java\pfc.jar -d . %*
Run it like this:


Here is a C shell script that will compile J-Link Java code on Unix:

# jlink_javac.csh - Compile JLink Apps using Intralink JDK

setenv Proe_Install_Dir /opt/proeWildfire2.0_m200
setenv IL_Install_Dir /opt/proiclient3.3_m021
setenv CLASSPATH $IL_Install_Dir/sun4_solaris/lib/tools.jar
set path=( $IL_Install_Dir/sun4_solaris/jre/bin $path )

java -classpath $Proe_Install_Dir/text/java/pfc.jar -d . $*
Run it like this:


The resulting class files will be in the current directory. While I do use this for my own J-Link code which is typically targeted at Java 1.4.2, it may not work with newer Java versions, nor take advantage of their full capabilities. However, for you command line junkies out there, this is just the recipe.


nomoslogos said...
This comment has been removed by the author.
nomoslogos said...

Very helpful! It works great for compiling, but when I tried to run the compiled program in Intralink it won't run. I get a blank error message box.
I was trying to compile my Intralink script this way becuase when I compile two related class files Intralink, it doesn't recognize the helper class when I compile the main class.
Any idea what I'm doing wrong when compiling in I-link, or does it only recognize one file at a time?
Thanks for the very informative blog!