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

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

Need help for starting jlink in eclipse or Netbeans

pt-2
1-Newbie

Need help for starting jlink in eclipse or Netbeans

Hi,

For the past few days I was looking for a right way to find a solution for this.. I know some basic java.since I already worked in c#,vba&VB.nt..

I searched this entire forum ,but still I'm not getting where to start jlink in eclipse or netbeans ..I can run a sample file..I understand the importance of protk.DAT and config.pro ,pfc.jar,jdk/jre version etc..so these are my questions:

1.should I need to create a package or  .java or a .class file in eclipse/netbeans to start?

2.Even if create a java file with start& stop methods, I'm not able to debug in eclipse (mars) with jdk 1.8 for creo 2.0..after setting debug configuration in eclipse.. I got VM refused error..but I did registered my protk.DAT file with creo & java_jlink_command within java.exe-****8000***..still no luck..so how to dubug exactly in eclipse/netbeans?

3.My sample program is jar file. for that its working fine..but if I extract and change the path in protk.DAT also its not seems to be working.. So i don't know what is the mistake I have done  ?

So I hope someone can help me to get the proper way to kick off this jlink.thank you...

FYI : I already worked in few cad customization projects using other programming languages..but I'm just a beginner in java.notes


This thread is inactive and closed by the PTC Community Management Team. If you would like to provide a reply and re-open this thread, please notify the moderator and reference the thread. You may also use "Start a topic" button to ask a new question. Please be sure to include what version of the PTC product you are using so another community member knowledgeable about your version may be able to assist.
1 ACCEPTED SOLUTION

Accepted Solutions

Prakash -

Getting a new program to work does take some effort, especially when you're new to the environment. If this were one of my programs, I would have to assume that there are many mistakes to resolve before I get it to work the first time.

In my creo installation folder i didn't find any JRE folders to map java.exe .here is the folder structure  "C:\tcwtxpocdata\PTC\Creo 2.0\Common Files\M150\x86e_win64\obj" after that there is no JRE\JDK folder..So shall i copy JDK folders manually to this location?

I don't recommend copying content like that into your Creo Parametric installation. You might try updating your installation by re-installing just the JLink component of Creo Parametric.  I checked my own Creo Parametric 2.0 installation and noted that JRE was installed under Common Files\M100\x86e_win64\obj . You could also continue doing what you are trying now, which is to use a JRE installed outside of Creo.

Again, there are many reasons why your application isn't launching.  Here are a few things you should check:

  1. Your java_app_classpath is most likely incorrect. Try adding \bin to the end of it.
  2. Do you have pfc.jar referenced anywhere in your CLASSPATH?  You can do this in the CLASSPATH environment variable or in java_app_classpath line.  I have noticed that java_app_classpath does have a limit to the number of characters it supports, so I put only the application's folder or .jar file there.
  3. You shouldn't declare start, stop or OnCommand with throws jxthrowable .  You need to write a try/catch block to handle those exceptions.
  4. You need a better package for your program than simply "com". You could try "com.prakash" for now.

Good luck with this. It always takes time to get started in a new programming environment.


|+|  M a r k  |+|

View solution in original post

3 REPLIES 3

Hi Prakash -

You should be able to use either Eclipse or NetBeans for your JLink projects. I used NetBeans about 10 years ago, but I have since switched to Eclipse. Most of the JLink programmers I talk to also use Eclipse.

1.should I need to create a package or  .java or a .class file in eclipse/netbeans to start?

Yes, you will need to create either. Since you want to use a debugger (and I consider that a good idea), I suggest that you use the .class files created by your IDE for debugging. When you're ready to send your JLink application to your users, that's the best time to create a .jar file.

2.Even if create a java file with start& stop methods, I'm not able to debug in eclipse (mars) with jdk 1.8 for creo 2.0..after setting debug configuration in eclipse.. I got VM refused error..but I did registered my protk.DAT file with creo & java_jlink_command within java.exe-****8000***..still no luck..so how to dubug exactly in eclipse/netbeans?

It looks like you know something about specifying debugging options in your java.exe command. I know only one way to do that, and that is to specify the java.exe command in the environment variable PRO_JAVA_COMMAND.  This is what I use:

C:\Program Files\Creo 3.0\M050\Common Files\x86e_win64\obj\JRE\bin\java.exe -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000

Make sure you use the same settings in your IDE.

3.My sample program is jar file. for that its working fine..but if I extract and change the path in protk.DAT also its not seems to be working.. So i don't know what is the mistake I have done  ?

When I run JLink programs that are not contained in a .jar file, I set the java_app_classpath field to be the \bin folder created by my Java compiler.

|+|  M a r k  |+|

Hi Mark,

Thanks for your guidance.But ,In my creo installation folder i didn't find any JRE folders to map java.exe .here is the folder structure  "C:\tcwtxpocdata\PTC\Creo 2.0\Common Files\M150\x86e_win64\obj" after that there is no JRE\JDK folder..So shall i copy JDK folders manually to this location?

Also kindly guide me where i'm going wrong as per the following steps:

1.Created new Java Application->new package->New class file in eclipse

DebugConfigurations.jpg

2.Above image is showing my Debug configuration Settings.

3.Written this program from another forum..

package com;

import java.io.IOException;

import com.ptc.cipjava.jxthrowable;

import com.ptc.pfc.pfcCommand.DefaultUICommandActionListener;

import com.ptc.pfc.pfcCommand.UICommand;

import com.ptc.pfc.pfcGlobal.pfcGlobal;

import com.ptc.pfc.pfcSession.Session;

public class LaunchCal {

  public static String MSG_FILE = "messages.txt";

  

   public static void start() throws jxthrowable {

     Session currentSession = pfcGlobal.GetProESession();

  

     String commandString = currentSession.GetMessageContents(

       MSG_FILE, "-L.launcher.cmd", null);

     String iconFile = currentSession.GetMessageContents(

       MSG_FILE, "-L.launcher.ico", null);

  

     UICommand cmd = currentSession.UICreateCommand("launcher",

       new MenuButtonListener(commandString, currentSession));

     cmd.SetIcon(iconFile);

     cmd.Designate(MSG_FILE, "-L.launcher.label", null, null);

   }

  

   public static void stop() { /* EMPTY */ }

}

class MenuButtonListener extends DefaultUICommandActionListener {

   private String commandString;

   private Session currentSession;

  

   public MenuButtonListener(String cmd, Session session) {

     commandString = cmd;

     currentSession = session;

   }

  

   public void OnCommand() throws jxthrowable {

     try {

       ProcessBuilder pb = new ProcessBuilder(commandString);

       pb.start();

     } catch (IOException e) {

       currentSession.UIShowMessageDialog(

         "Could not start " + commandString, null);

     }

   }

  }

4.After that  ,i changed the environment variables as you suggested ,name -PRO_JAVA_COMMAND value- C:\Program Files\Java\jre1.8.0_60\bin\java.exe-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000.

5.Then i changed the protk.dat location & deleted jlink_java_command in configuration editor..after that clicked Auxiliary Applications in utilities to register the program..

then i clicked start button ,i got this error

..Failed.jpg

This is my prot file

NAME                LaunchCal

STARTUP             JAVA

JAVA_APP_CLASS      com.LaunchCal

JAVA_APP_START      start

JAVA_APP_STOP       stop

JAVA_APP_CLASSPATH  C:\Users\xxx\workspace\Calculator

TEXT_DIR            C:\Users\xxx\workspace\Calculator

ALLOW_STOP          TRUE

DELAY_START         TRUE

END

my class path C:\Users\xxxxx\workspace\Calculator\bin\com

Folder.jpg

This is my Folder structure

com.jpg

So kindly help me ..where exactly i'm making mistake...Thank you

Prakash -

Getting a new program to work does take some effort, especially when you're new to the environment. If this were one of my programs, I would have to assume that there are many mistakes to resolve before I get it to work the first time.

In my creo installation folder i didn't find any JRE folders to map java.exe .here is the folder structure  "C:\tcwtxpocdata\PTC\Creo 2.0\Common Files\M150\x86e_win64\obj" after that there is no JRE\JDK folder..So shall i copy JDK folders manually to this location?

I don't recommend copying content like that into your Creo Parametric installation. You might try updating your installation by re-installing just the JLink component of Creo Parametric.  I checked my own Creo Parametric 2.0 installation and noted that JRE was installed under Common Files\M100\x86e_win64\obj . You could also continue doing what you are trying now, which is to use a JRE installed outside of Creo.

Again, there are many reasons why your application isn't launching.  Here are a few things you should check:

  1. Your java_app_classpath is most likely incorrect. Try adding \bin to the end of it.
  2. Do you have pfc.jar referenced anywhere in your CLASSPATH?  You can do this in the CLASSPATH environment variable or in java_app_classpath line.  I have noticed that java_app_classpath does have a limit to the number of characters it supports, so I put only the application's folder or .jar file there.
  3. You shouldn't declare start, stop or OnCommand with throws jxthrowable .  You need to write a try/catch block to handle those exceptions.
  4. You need a better package for your program than simply "com". You could try "com.prakash" for now.

Good luck with this. It always takes time to get started in a new programming environment.


|+|  M a r k  |+|

Top Tags