Cancel
Showing results for 
Search instead for 
Did you mean: 

NX Open using Java Thread class

Creator
Creator

Hi,

 I have an NXOpen java application that uses the java.lang.Thread class

It works on NX6 but when I tried it on NX8.5 it did not. There are no Error messages

A simple code is attached

import java.rmi.RemoteException;
import nxopen.BaseSession;
import nxopen.NXException;
import nxopen.Session;
import nxopen.SessionFactory;


public class Test extends Thread {

	Session m_session;

public Test() throws NXException {
	this.m_Session = (Session) SessionFactory.get("Session");
}

public void run() {
	try {
		m_Session.listingWindow().open();
		m_Session.listingWindow().writeLine("In the Thread");
	}
	catch (RemoteException e) {
		e.printStackTrace();
	}
	catch (NXException e) {
		e.printStackTrace();
	}
}

public static final int getUnloadOption() {
	return BaseSession.LibraryUnloadOption.IMMEDIATELY;
}

public static void main( String[] args ) throws NXException {
	Test t = new Test();
	t.start();
}

}

 

Moti Eitan
1 REPLY

Re: NX Open using Java Thread class

Creator
Creator

found it!

I changed the function:

// old code
/*
public static final int getUnloadOption() {
	return BaseSession.LibraryUnloadOption.IMMEDIATELY;
}
*/
//new code:
public static final int getUnloadOption() {
	return BaseSession.LibraryUnloadOption.EXPLICITLY;
}

 Now it seems to be working

Moti Eitan