Hello,
I am trying to customize Pro-E using J-link.
But while running the J-link Program, I am getting error as "Startup of Application failed"
.
The Protk.dat file was placed at "<Pro-E install directory>/text" path.
Protk.dat file is as below:
================================================
name JLinkHelloWorld-App
startup java
java_app_class JLinkHelloWorld
java_app_start start
java_app_stop stop
allow_stop true
delay_start false
text_dir C:\JLinkHelloWorld\text
java_app_classpath C:\JLinkHelloWorld\JLinkHelloWorld;C:/Users/228361/Desktop/D imension_Numbering/pfc.jar
end
====================================================
and java program is:
package com.cognizant.jlinkDemo;
import java.io.FileWriter;
import com.ptc.cipjava.jxthrowable;
import com.ptc.cipjava.stringseq;
//import com.ptc.pfc.Implementation.Starter;
import com.ptc.pfc.pfcGlobal.pfcGlobal;
import com.ptc.pfc.pfcSession.Session;
public class JLinkHelloWorld {
static JLinkHelloWorld App = null;
String programName = null;
String directoryName = null;
Session session = null;
FileWriter log = null;
String msgFile = "msg_jlinkhelloworld.txt";
String newline = null;
//Constructor of Class file
public JLinkHelloWorld(){
programName = this.getClass().getName();
try{
log = new FileWriter(programName + ".log");
newline = System.getProperty("line.separator");
directoryName = session.GetCurrentDirectory();
}
catch(Exception e){
}
}
//Displaying message in Pro-Engineer
public void displayMessage(String msg) throws Exception{
stringseq seq = stringseq.create();
seq.set(0, msg);
session.UIDisplayMessage(msgFile, "JLHW %s", seq);
session.UIShowMessageDialog(directoryName, null);
seq.clear();
writeLog(msg);
}
//Write text to log file
public void writeLog(String msg){
try{
if (log == null){
return;
}
log.write(msg+newline);
log.flush();
}
catch (Exception e){
}
}
// tile to close log file
public void closeLog(){
try{
if (log == null){
return;
}
}
catch (Exception e){
}
}
/************************************************
* public static void main(String args[]){
*
*
* System.out.println("this is proE start up");
* JLinkHelloWorld j = new JLinkHelloWorld();
* j.start();
* System.out.println("after the startup");
*
}
**************************************************/
// Called by Pro-E when starting the application
public void start(){
try{
App = new JLinkHelloWorld();
App.startupApplication();
}
catch (Exception e){
App.writeLog("Problem running startupApplication method"+e.toString());
System.out.println("Exception thrown:"+e.getMessage());
return;
}
}
// Called by Pro-E when stopping the application
public static void stop(){
try{
App.stopApplication();
}
catch (Exception e){
App.writeLog("Problem running shutdownApplication method" + e.toString());
return;
}
}
// How startupApplication method will work
public void startupApplication() throws Exception {
try{
writeLog("Application '" + programName + "' started");
session = pfcGlobal.GetProESession();
}
catch (jxthrowable x){
writeLog("Error: Problem while getting session object..");
return;
}
}
//How stopApplication method will work
public void stopApplication()throws Exception{
writeLog("Application '" + programName + "' stopped");
closeLog();
}
}
I am trying to customize Pro-E using J-link.
But while running the J-link Program, I am getting error as "Startup of Application failed"
The Protk.dat file was placed at "<Pro-E install directory>/text" path.
Protk.dat file is as below:
================================================
name JLinkHelloWorld-App
startup java
java_app_class JLinkHelloWorld
java_app_start start
java_app_stop stop
allow_stop true
delay_start false
text_dir C:\JLinkHelloWorld\text
java_app_classpath C:\JLinkHelloWorld\JLinkHelloWorld;C:/Users/228361/Desktop/D imension_Numbering/pfc.jar
end
====================================================
and java program is:
package com.cognizant.jlinkDemo;
import java.io.FileWriter;
import com.ptc.cipjava.jxthrowable;
import com.ptc.cipjava.stringseq;
//import com.ptc.pfc.Implementation.Starter;
import com.ptc.pfc.pfcGlobal.pfcGlobal;
import com.ptc.pfc.pfcSession.Session;
public class JLinkHelloWorld {
static JLinkHelloWorld App = null;
String programName = null;
String directoryName = null;
Session session = null;
FileWriter log = null;
String msgFile = "msg_jlinkhelloworld.txt";
String newline = null;
//Constructor of Class file
public JLinkHelloWorld(){
programName = this.getClass().getName();
try{
log = new FileWriter(programName + ".log");
newline = System.getProperty("line.separator");
directoryName = session.GetCurrentDirectory();
}
catch(Exception e){
}
}
//Displaying message in Pro-Engineer
public void displayMessage(String msg) throws Exception{
stringseq seq = stringseq.create();
seq.set(0, msg);
session.UIDisplayMessage(msgFile, "JLHW %s", seq);
session.UIShowMessageDialog(directoryName, null);
seq.clear();
writeLog(msg);
}
//Write text to log file
public void writeLog(String msg){
try{
if (log == null){
return;
}
log.write(msg+newline);
log.flush();
}
catch (Exception e){
}
}
// tile to close log file
public void closeLog(){
try{
if (log == null){
return;
}
}
catch (Exception e){
}
}
/************************************************
* public static void main(String args[]){
*
*
* System.out.println("this is proE start up");
* JLinkHelloWorld j = new JLinkHelloWorld();
* j.start();
* System.out.println("after the startup");
*
}
**************************************************/
// Called by Pro-E when starting the application
public void start(){
try{
App = new JLinkHelloWorld();
App.startupApplication();
}
catch (Exception e){
App.writeLog("Problem running startupApplication method"+e.toString());
System.out.println("Exception thrown:"+e.getMessage());
return;
}
}
// Called by Pro-E when stopping the application
public static void stop(){
try{
App.stopApplication();
}
catch (Exception e){
App.writeLog("Problem running shutdownApplication method" + e.toString());
return;
}
}
// How startupApplication method will work
public void startupApplication() throws Exception {
try{
writeLog("Application '" + programName + "' started");
session = pfcGlobal.GetProESession();
}
catch (jxthrowable x){
writeLog("Error: Problem while getting session object..");
return;
}
}
//How stopApplication method will work
public void stopApplication()throws Exception{
writeLog("Application '" + programName + "' stopped");
closeLog();
}
}