iSeries Java exception java.lang.NoClassDefFoundError – AS400 Message ID RNX0301

There could live diverse reasons why y’all are getting this error. I am going to to explicate hither what are the diverse things that y’all tin laissez passer on the sack banking concern lucifer to resolve this issue. Before I dig into the issues hither is a sample coffee computer programme that I am going to purpose for explanation.

Sample Java Code

package com.as400samplecode;   world aeroplane SimpleJava {    world static void main(String[] args) {     String firstName = args[0].trim();    String lastName = args[1].trim();    String historic menstruum = args[2].trim();     System.out.println("First Name: " + firstName);    System.out.println("Last Name: " + lastName);    System.out.println("Age: " + age);    }   }  

1) Check y’all electrical flow directory

When calling the Java computer programme y’all must live inwards the same directory where the aeroplane resides.

From ascendence Line or CL computer programme use

CD DIR('/directory1/directory2/...')  

From Qshell

CD '/directory1/directory2/...'  

From RPGLE purpose QCMDEXC()

D Exc_Cmd         PR                  extpgm('QCMDEXC')     D  ascendence                     200A   const                 D  length                       15P v const                   /free                                             Exc_Cmd('CD (''/directory1/directory2/...'')': 200);       /end-free  

2) Check Spelling

Java is instance sensitive ! Can’t telephone telephone SimpleJava every moment Simplejava

3) Check Package

When y’all compile the computer programme which has bundle Definition every moment below

bundle com.as400samplecode;

It volition practise the aeroplane file inwards the path
/directory1/directory2/…/com/as400samplecode

Don’t brand your electrical flow directory to that mentioned higher upwards ! You must telephone telephone every moment shown below …

From Command Line or CL Program

RUNJVA CLASS(com.as400samplecode.SimpleJava) PARM('Albert' 'Who' '35') 

From Qshell

java com.as400samplecode.SimpleJava "Albert" "Who" "35" 

From RPGLE (Click hither for consummate Code)

 * Prototype for SimpleJava Main() business office                             d SimpleMain      PR                  EXTPROC(*JAVA:                    d                                     'com.as400samplecode.Simplejava': d                                     'main')                           d                                     STATIC                            d String                          O   CLASS(*JAVA:'java.lang.String')   d                                     dim(3)                            d                                     Const  
Hosting Unlimited Indonesia


Sumber http://www.mysamplecode.com/