cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

Can anyone please help me on run pfcAsyncFullExample program creo using

SOURABH
5-Regular Member

Can anyone please help me on run pfcAsyncFullExample program creo using

package com.ptc.jlinkasyncexamples;

import com.ptc.cipjava.*;
import com.ptc.pfc.pfcSession.*;
import com.ptc.pfc.pfcCommand.*;
import com.ptc.pfc.pfcAsyncConnection.*;
import com.ptc.pfc.pfcExceptions.*;

/**
* This asynchronous class is a fully asynchronous application. It follows
* the procedure for a full asynchronous application:
* 1.) the application establishes listeners for Pro/ENGINEER events (in
* this case, the menu button and the termination listener)
* 2.) the application goes into a control loop calling EventProcess()
* which allows the application to respond to the Pro/ENGINEER events.
*/
public class pfcAsyncFullExample extends AsyncActionListener_u
{

private AsyncConnection connection;
private boolean exit_flag = false;

public static void main (String [] args) throws com.ptc.cipjava.jxthrowable
{
if (args.length != 2)
{
printMsg ("Incorrect argument list.");
printMsg ("Arguments: java com.ptc.jlinkasyncexamples.pfcAsyncFullExample <pro/E command> <text path>");
return;
}

try
{
System.loadLibrary ("jotkasync");
}
catch (UnsatisfiedLinkError error)
{
printMsg ("Could not load J-Link library pfcasyncmt.");
return;
}

new pfcAsyncFullExample (args);
}

// Constructor
private pfcAsyncFullExample (String args[]) throws com.ptc.cipjava.jxthrowable
{
startProE (args);
addTerminationListener ();
addMenuButton();

while (!exit_flag)
{
// Could do other regualar processing here, but the EventProcess()
// calls should happen regularly, so that Pro/ENGINEER does not
// appear slow in responding to menu button picks
try
{
connection.EventProcess ();
Thread.sleep (100);
}
catch (java.lang.InterruptedException ex)
{
}
}

// Wait here a bit so Pro/ENGINEER can finish shutting down.
try
{
Thread.sleep (2000);
connection.EventProcess ();
}
catch (java.lang.InterruptedException ex)
{
}
}

/**
* Starts Pro/ENGINEER.
*/
void startProE (String[] args) throws com.ptc.cipjava.jxthrowable
{
try
{
// args[0] = Pro/ENGINEER command
// args[1] = text path for menu/message files
connection = pfcAsyncConnection.AsyncConnection_Start (args [0], args[1]);
}
catch (XToolkitGeneralError error)
{
printMsg ("Could not start Pro/ENGINEER.");
System.exit (0);
}

return;
}

/**
* Adds a menu and a menu button to the Pro/E menubar.
*/
void addMenuButton () throws com.ptc.cipjava.jxthrowable
{
Session s = connection.GetSession ();
UICommand cmd = s.UICreateCommand ( "AsyncCommand", (UICommandActionListener) new ButtonListener());

s.UIAddMenu ("J-Link", "Applications", "menu_text.txt", null);
s.UIAddButton (cmd, "J-Link", null, "AsyncApp", "AsyncAppHelp", "menu_text.txt");
}

/**
* Adds a handler for Pro/ENGINEER's exit.
*/
void addTerminationListener () throws com.ptc.cipjava.jxthrowable
{
connection.AddActionListener ((AsyncActionListener)this);
printMsg ("Termination listener added.");
}

/**
* Termination handler - from the AsyncActionListener interface.
*/
public void OnTerminate (TerminationStatus status)
{
printMsg ("Pro/ENGINEER shutting down.");

exit_flag = true;
}

public static void printMsg (String msg)
{
System.out.println (msg);
}
}

class ButtonListener extends DefaultUICommandActionListener
{
/**
* Menu button action - from interface UICommandActionListener
*/
public void OnCommand ()
{
pfcAsyncFullExample.printMsg ("User menu button pushed.");

}
}

 

while running this program iam getting this error

1 REPLY 1
Top Tags