Jump to content
Excelsior Forums
Sign in to follow this  
tkleiber

Error: "Class <...> not found" at runtime

Recommended Posts

I define following in my code:


public class execLoader_jpi extends VBean {

...

?private boolean createProcess(String lpCommandLine, int dwCreationFlags,

? ?startupInfo lpStartupInfo, processInformation lpProcessInformation) {

? ?try {

? ? ?System.out.println("Start createProcess");

? ? ?xFunction oFunction = new xFunction("kernel32",

? ? ? ? ?"int CreateProcessA(CSTRING, CSTRING, de.ikb.forms.execLoader_jpi.securityAttributes*, " +

? ? ? ? ?"de.ikb.forms.execLoader_jpi.securityAttributes*, boolean, int, int, CSTRING, " +

? ? ? ? ?"de.ikb.forms.execLoader_jpi.startupInfo*, de.ikb.forms.execLoader_jpi.processInformation*)");

? ? ?System.out.println("create Arguments");

...

?class securityAttributes extends Structure {

? ?int nLength;

? ?int lpSecurityDescriptor;

? ?boolean bInheritHandle;

? ?public securityAttributes() {

? ?}

? ?public String defineLayout() {

? ? ?return "int nLength, int lpSecurityDescriptor, boolean bInheritHandle";

? ?}

?}

}


I have tried with / without full package declaration in signature and with local class to createProcess method. I get always at runtime error messages similar to:


Start createProcess

Class 'de.ikb.forms.execLoader_jpi.securityAttributes' not found

Share this post


Link to post
Share on other sites

Get the same error when I test the example where.java, which is the delivered with trial version of xFunction:

com.excelsior.xFunction.IllegalSignatureException: Class 'WIN32_FIND_DATA' not found

But sample11.java works. The only difference I see, in sample11.java in the default constructor of the class is initialized an array szCSDVersion.

I'm using Sun SDK 1.4.2_03

Share this post


Link to post
Share on other sites

The fully qualified name for class securityAttributes is

"de.ikb.forms.execLoader_jpi$securityAttributes", but not "de.ikb.forms.execLoader_jpi.securityAttributes"

BTW, have checked Where sample with 1.4.2_03, but found no problems. Maybe you had modified it somehow?

Share this post


Link to post
Share on other sites

Ok! Have changed the full name of the classes but get a new error yet:

Structure subclass 'de.ikb.forms.execLoader_jpi$processInformation' must have constructor without arguments

com.excelsior.xFunction.IllegalSignatureException: Structure subclass 'de.ikb.forms.execLoader_jpi$processInformation' must have constructor without arguments

But I have defined the constructor:

 class processInformation extends Structure {

   int hProcess;

   int hThread;

   int dwProcessId;

   int dwThreadId;

   public processInformation() {

   }

   public String defineLayout() {

     return "int hProcess, int hThread, int dwProcessId, int dwThreadId";

   }

 }

Share this post


Link to post
Share on other sites

Non-static internal classes can't be used as arguments, because of additional implicit argument (this of enclosing class) is passed into constructor.

In your case, it is recommended to make securityAttributes and processInformation static, e.g.

static class securityAttributes ...

Share this post


Link to post
Share on other sites

Ok, I this helps me an step further. At this time I make my call:

...

     System.out.println("Start createProcess>" + lpCommandLine + "<");

     System.out.println("lpStartupInfo.wShowWindow>" + lpStartupInfo.wShowWindow + "<");

     System.out.println("lpStartupInfo.dwFlags>" + lpStartupInfo.dwFlags + "<");

     xFunction oFunction = new xFunction("kernel32",

         "int CreateProcessA(CSTRING, CSTRING, de.ikb.forms.execLoader_jpi$securityAttributes*, " +

         "de.ikb.forms.execLoader_jpi$securityAttributes*, int, int, int, CSTRING, " +

         "de.ikb.forms.execLoader_jpi$startupInfo*, " +

         "de.ikb.forms.execLoader_jpi$processInformation*)");

     System.out.println("create Arguments");

     Argument[] arrArgs = new Argument[10];

     arrArgs[0] = new Argument("", Argument.CSTRING);

     arrArgs[1] = new Argument(lpCommandLine, Argument.CSTRING);

     arrArgs[2] = Pointer.createPointerTo(new securityAttributes());

     arrArgs[3] = Pointer.createPointerTo(new securityAttributes());

     arrArgs[4] = new Argument(0);

     arrArgs[5] = new Argument(1);

     arrArgs[6] = new Argument(0);

     arrArgs[7] = new Argument("", Argument.CSTRING);

     arrArgs[8] = Pointer.createPointerTo(lpStartupInfo);

     arrArgs[9] = Pointer.createPointerTo(lpProcessInformation);

     int intRet = ((Integer) oFunction.invoke(arrArgs)).intValue();

     System.out.println("intRet>" + intRet + "<");

...

My outputs shows following:

...

Start createProcess>Notepad.exe<

lpStartupInfo.wShowWindow>1<

lpStartupInfo.dwFlags>1<

create Arguments

intRet>0<

...

Return 0 should mean that notepad is opened.

But notepad is not opened as I want. I cannot see it on desktop or in task manager as I want.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×