All,
I this is my first attempt at calling Java from RPG and I am about to pull my hair out.
I have a .jar for from a third party vendor that I am trying to communicate with named CGProCLI.jar.
I tried my own directory at first but the .jar currently resides in the QIBM/UserData/Java400/ext directory and it’s my understanding that I don’t even need to set the class path to there as it’s a default, but I set the classpath anyway.
I have spent quite some time reading and looking at various examples on the web and even created my own java program on the 400 and compiled it in above directory and got it to work. Every time I run this I get the dreaded java.lang.NoClassDefFoundError error. I have included my prototype, RPG, the java code from the third party and my errors. I am sure this is something really silly on my part, but any help would be appreciated.
Thanks, Jon
* Connect method
D CGConnect S O CLASS(*JAVA:'CGProCLI')
* Connect method
D new_CGConnect...
D PR Like(CGConnect)
D ExtProc(*JAVA:'CGProCLI'
D :*CONSTRUCTOR)
D CGConnect2...
D PR
D ExtProc(*JAVA:'CGProCLI'
D :'CGProCLI')
* method parameters
D host O Class(*JAVA:'java.lang.String')
D Const
D port O Class(*JAVA:'java.lang.String')
D Const
D login O Class(*JAVA:'java.lang.String')
D Const
D password O Class(*JAVA:'java.lang.String')
D Const
And finally the code:
D Conn S like(CGConnect)
*
/Free
shost = newString(%trim(host));
sport = newString(%trim(port));
slogin = newString(%trim(login));
spassword = newString(%trim(password));
Conn = new_CGConnect(); This is where it blows.
RtnCode = CGConnect2(Conn:sHost:sPort+
sLogin:sPassword);
/End-Free
The java code:
public CGProCLI(String host,int port,String user,String password) throws CGProException {
openStream(host,port);
connect(user,password);
}
And the ever too popular error:
Cause . . . . . : RPG procedure CG0001 in program GDSBILLBLD/CG0001 received
Java exception "java.lang.NoClassDefFoundError: CGProCLI" when calling
method "<init>" with signature "()V" in class "CGProCLI".
When I run:
echo $CLASSPATH | tr ":" "\n"
I get:
'.
/QIBM/UserData/Java400/ext/CGProCLI.jar
_________________________________________________________________
Need to know the score, the latest news, or you need your Hotmail®-get your "fix".
http://www.msnmobilefix.com/Default.aspx
As an Amazon Associate we earn from qualifying purchases.