J-Link is a Java toolkit for Creo® Parametric. It makes possible the development of Java programs which can be used to interact with Creo Parametric.
J-Link comes with Creo® and is free of charge. In order to install It, make sure to select the “API Toolkits” component during Creo® installation.
- Creo® Parametric (2.0 M010 has been used for this tutorial)
- J-Link installed
- Java (As specified in http://www.ptc.com/partners/hardware/current/jlink.htm) :
- JDK 1.4.1 or above
- JRE 1.5 or above
- Java language
- Creo® Parametric
1.2.Synchronous J-Link application
A synchronous J-Link application is started and managed by Creo® Parametric.Control belongs to either Creo® Parametric or the application, but not both at the same time. This tutorial covers this type of applications.
1.3.Asynchronous J-Link application
An asynchronous application is started independent of Creo® Parametric with the option to start or connect to Creo® Parametric processes. This tutorial does not covers this type of application.
|<CREO_LOADPOINT>||The location where the Creo® applications are installed,such as :C:\Program Files\PTC\Creo 2.0|
|<DATECODE>||CREO® datecode such as M010, M020….|
|<JLINK_LOADPOINT>||The location where J-Link is installed:<CREO_LOADPOINT>\CommonFiles\<DATECODE>\jlink|
|<JLINK_APP_TEXT>||J-Link application resources directory|
J-Link comes with very usefull resources, such as a documentation, examples…. These resources are available under the <JLINK_LOADPOINT> directory.
2.1.J-Link synchronious application jar
The J-Link synchronious application jar is located at :
A J-Link java application must provide a class with two public static methods:
- The start method : Called by Creo® parametric to start the application
- The stop method : Called by Creo® parametric to stop the application
Both methods must be contained in a single public class with the following declaration :
public static xxxx();
Where xxxx is the method name.
A J-Link application should provide a directory containing text resource bundles, images…Localized or not.This directory is designated as <JLINK_APP_TEXT>.
Note that in this tutorial, we consider non-localized resources as It is simplier.
Text files should be under <JLINK_APP_TEXT> and images should be under <JLINK_APP_TEXT>\resource
3.1.J-Link text resource bundle
A text resource bundle consists on a text file defining keys and values, as follow:
Text resource bundles are used by the J-Link APIs in order to render text.
In order be loaded by Creo® parametric a J-Link application must be described in a registry file, which is a simple text where evey line consists on a predefined key and a value. The name of this file may be important (Depending on how It is registered) , please refer to 4.1.
|name||The name of the application|
|startup||For J-Link application, the value must be java|
|java_app_class||The java class of the application (including eventual packages)|
|java_app_classpath||Extra Java classpath of the application, may be separated by ; (on Windows) and : (on Unix)|
|java_app_start||The start method name. The signature must be public static XXXX();|
|java_app_stop||The stop method name. The signature must be public static XXXX();|
|allow_stop||Boolean defining if the application can be stopped.|
|delay_start||Defines if the application is loaded on startup or not (value can be true or false)|
|text_dir||The resource directory, more information will be provided later on this chapter.|
|end||The end keyword, It does not needs value.|
Note that more than one application can be declared in one registry file.
4.1.Registry file registration
There are various ways to make Creo® Parametric registering an application registry file (Not all ways are presented here, for more information, please refer to the J-Link User’s Guide).
- Define the registry file (Full path) in a creotkdat, protkdat, prodevdat, or toolkit_registry_file statement in the Creo Parametric configuration file.
- Put the registry file under <CREO_LOADPOINT>\Common Files\<DATECODE>\text and rename it to creotk.dat, protk.dat, or prodev.dat.
- Save your file with a dat extension and register It manually throught the user interface (Utilities >> Auxiliary Applications >> Register).
Option 1 is preferred for production, Option 3 is useful for development.
On the second part, we are going to develop a simple “Hello world” J-Link application.