1.Introduction

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.

1.1.Prerequists

1.1.1.Software

1.1.2.Knowledge

  • 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.

1.4.Terminology

Term Description
<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

 

1.5.Additional resources

J-Link comes with very usefull resources, such as a documentation, examples…. These resources are available under the <JLINK_LOADPOINT> directory.

2.Java application

2.1.J-Link synchronious application jar

The J-Link synchronious application jar is located at :

<CREO_LOADPOINT>/<DATECODE>/text/java/pfc.jar

2.2.Entry points

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.

3.J-Link resources

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:

KEY1

VALUE1

#

#

KEY2

VALUE2

#

#

[…]

Text resource bundles are used by the J-Link APIs in order to render text.

4.Registry file

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.

Predefined key Description
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).

  1. Define the registry file (Full path) in a creotkdat, protkdat, prodevdat, or toolkit_registry_file statement in the Creo Parametric configuration file.
  2. Put the registry file under <CREO_LOADPOINT>\Common Files\<DATECODE>\text and rename it to creotk.dat, protk.dat, or prodev.dat.
  3. 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.