Showing results for 
Search instead for 
Did you mean: 

JAVA:Error as NXOpen User Function - Works from Command line


Hi there,

when I am executing the .class file of this java code as NXOpen User Function (File-> Execute-> NXopen...):


package testproject;

import nxopen.*;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;

public class Test
  public static void main(String [] args) throws Exception

     String xls_path = "C:\\MASTER.xls";
       NPOIFSFileSystem fs = new NPOIFSFileSystem(new File(xls_path));
       HSSFWorkbook wb = new HSSFWorkbook(fs.getRoot(), true);


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


I am getting the error: "A JAVA exception was encountered" in NX. When I am running the .class file from command line - it works great. What am I doing wrong ?

Thanks in advance !


Re: JAVA:Error as NXOpen User Function - Works from Command line

Siemens Phenom Siemens Phenom
Siemens Phenom


You could try getting the NX session.  I realize you are not actually calling any NX Open methods, but maybe NX wants you to get the session when you run interactively.  I don't know for sure whether it will make a difference, but it would be a simple test.