|
Hi all I have a need to call a java program from RPG. Here is my
prototypes:
d Levenshtein pr o extproc(*java:
d 'levenshtein.Difference':
d *constructor)
d LD pr 10i 0 extproc(*java:
d
'levenshtein.Difference':
d 'LD')
d iString1 like(String1)
d iString2 like(String1)
d Class s o class(*java:
d 'levenshtein.Difference')
d String1 s o CLASS(*JAVA:'java.lang.String')
/free
// constructor for java class
Class = Levenshtein();
When I try to call the above constructor I get an RNX0301 NoClassDefFound
Here is my java program:
The Program is in a Jar file located in QIBM\UserData\Java400\ext
Is this the default directory for the classpath var or do i have to change
it to look here?
package levenshtein;
public class Difference {
//*****************************
// Compute Levenshtein distance
//*****************************
public int LD (String s, String t) {
int d[][]; // matrix
int n; // length of s
int m; // length of t
int i; // iterates through s
int j; // iterates through t
char s_i; // ith character of s
char t_j; // jth character of t
int cost; // cost
// Step 1
n = s.length ();
m = t.length ();
if (n == 0) {
return m;
}
if (m == 0) {
return n;
}
d = new int[n+1][m+1];
// Step 2
for (i = 0; i <= n; i++) {
d[i][0] = i;
}
for (j = 0; j <= m; j++) {
d[0][j] = j;
}
// Step 3
for (i = 1; i <= n; i++) {
s_i = s.charAt (i - 1);
// Step 4
for (j = 1; j <= m; j++) {
t_j = t.charAt (j - 1);
// Step 5
if (s_i == t_j) {
cost = 0;
}
else {
cost = 1;
}
// Step 6
d[i][j] = Minimum (d[i-1][j]+1, d[i][j-1]+1, d[i-1][j-1] +
cost);
}
}
// Step 7
return d[n][m];
}
// get minimum of three values
private int Minimum (int a, int b, int c) {
int mi;
mi = a;
if (b < mi) {
mi = b;
}
if (c < mi) {
mi = c;
}
return mi;
}
}
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.