× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I guess I would need to know what you think would be wrong. Most of the System i' s I work on have Java 1.4 as the default. Let's see what a brand spankin new JS12 with IBM i 6.1 says:

java -version java version "1.5.0" Java(TM) 2 Runtime Environment, Standard Edition (build pap32devifx-20080811b
(SR8a))
IBM J9 VM (build 2.3, J2RE 1.5.0 IBM J9 2.3 OS400 ppc-32 j9vmap3223sr8a-20080
811 (JIT enabled) J9VM - 20080809_21892_bHdSMr JIT - 20080620_1845_r8 GC - 200806_19) JCL - 20080811a
That's right as far as I can see. I would guess IBM would make the latest "stable" release the default. That is what I see: IBM Java 5, 32bit.

If I set my SystemDefault.properties file to use Java 1.4 and then log back in I get:

java -version java version "1.4.2" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_16-b05)
Classic VM (build 1.4, build JDK-1.4, native threads, jitc) $
Which is A-OK. All is well.

Nick needs to take a look at his Java version. Once he knows what version is running on i5/OS he can make the necessary adjustments to his environment so his call can run.

Pete


Doug Palme wrote:
I ran this for FYI just to see what our machine said......

Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_16-b05) Classic VM (build 1.4, build JDK-1.4, native threads, jitc_de)
That looks wrong......

then again, since I have no clue about Java, I am only guessing.

From: Pete Helgren <Pete@xxxxxxxxxx> To: RPG programming on the AS400 / iSeries <rpg400-l@xxxxxxxxxxxx> Date: 10/29/2008 04:37 PM Subject: Re: Calling Java from RPG
----------------------------------------------------------------------

What java version is i5/OS running? Quickest way to find out is to run
QSH and then type: java -version at the qsh command line.

Most like you are using a Java 5 specific method. The project build is
one thing. The actual execution of the class is another. Check to see
what i5/OS is running for the java version.

Pete

Nick Arndt wrote:
> Thanks for the help so far.
>
> I now can find my class, but it gives me a
> java.lang.UnsupportedClassVersionError
>
> The java program was created using RDi, I have set the project to
1.3,1.4
> and 5.0 but each time I get the same error.
> Any Idea?
>
> Thanks.
>
> On Wed, Oct 29, 2008 at 3:11 PM, Pete Helgren <Pete@xxxxxxxxxx> wrote:
>
> >> Nick,
>>
>> Barbara has already given you the key to solving the issue. This
>> particular issue is one that comes up in Java pretty often,
particularly
>> in learning curve mode.
>>
>> Java needs to find the class and the classpath is the only way. So if
>> you have only /JavaSrc on your classpath, all class resolution will
>> include that folder to begin with. But this isn't always clear because
>> you may just decide to copy a class file from one directory to another
>> and still expect it to work, just like copying an executable or batch
>> file from one folder to another works with other programs. Java is
>> different because it has a "package" declaration in the java source
>> itself that it uses to resolve the class. So if your java source has a
>> package declaration, the java class file has to be in a folder with the
>> same structure as the package. I won't go into the details as to why
>> this is necessary but take it as a "given" for now. There are other
ways
>> to load classes but we won't go into that either.
>>
>> So if you decide to create a java program with the package name of
>> "programs.nick.levenshtein" and create a class using that package name
>> and the class is called MyClass, then if your classpath has /JavaSrc it
>> in, your JavaSrc folder must also have a subfolder structure of
>> /programs/nick/levenshtein/ and the MyClass.class file should be in it.
>>
>> Invocation is also relative to that so if you were to execute the class
>> it would be programs/nick/levenshtein/MyClass.class and if the
classpath
>> has /JavaSrc in it, it would be one of the folders that would be
checked
>> for the path/class combination that your package declaration/Class name
>> determines. So in the invocation of
>> programs/nick/levenshtein/MyClass.class the classpath of /JavaSrc would
>> allow /programs/nick/levenshtein/MyClass.class to be found (remember?
>> You compiled into /JavaSrc/programs/nick/levenshtein/MyClass.class)
>>
>> So either remove any package declaration OR make sure that you have the
>> class in a folder that is a combination of a classpath folder plus your
>> package name (in a folder of the same structure with "/" in place of
the
>> "." in the package name)
>>
>> Hope this will help a bit more.
>>
>> Pete
>>
>>
>>
>> Nick Arndt wrote:
>> >>> Scott I have changed my prototype to this:
>>> d Levenshtein pr o extproc(*java:
>>> d 'Difference':
>>> d *constructor)
>>>
>>> d LD pr 10i 0 extproc(*java:
>>> d 'Difference':
>>> d 'LD')
>>> d iString1 like(String1)
>>> d iString2 like(String1)
>>>
>>> and moved my Difference.class to a new directory '/JavaSrc', and added
>>> >> that
>> >>> directory to my classpath.
>>>
>>> But I am still getting a noClassDef found error.
>>>
>>> Any Idea?
>>>
>>> Thanks.
>>>
>>> On Wed, Oct 29, 2008 at 12:48 PM, Scott Klement
>>> <rpg400-l@xxxxxxxxxxxxxxxx>wrote:
>>>
>>>
>>> >>>> Hi Nick,
>>>>
>>>> /QIBM/UserData/Java400/ext is the Java "extensions" directory. It's
>>>> supposed to be used for extensions to the Java language, not for your
>>>> own code.
>>>>
>>>> It's not the "default directory of your CLASSPATH" because it's not
part
>>>> of your CLASSPATH. Indeed, the files in that directory are loaded
>>>> before the CLASSPATH is even considered.
>>>>
>>>> One of the biggest problems with using the extensions directory is
that
>>>> any code in that directory is loaded automatically for every Java
>>>> program. That means you can never have two versions (such as test &
>>>> production versions) running on the same system, because the stuff in
>>>> the ext directory is *always* loaded first.
>>>>
>>>> My recommendation is that you remove it from the ext directory.
>>>> Instead, create your own directory. Maybe with something like this:
>>>>
>>>> CRTDIR ('/java')
>>>> CRTDIR ('/java/publicclasses')
>>>>
>>>> Put all of your classes you want to be available to everyone into
that
>>>> directory, and then set the CLASSPATH envvar to point to that
directory.
>>>>
>>>> ADDENVVAR ENVVAR(CLASSPATH) VALUE('/java/publicclasses')
>>>>
>>>> That's just a suggestion though. The reason your example doesn't
work
>>>> is that it's expecting the Difference class to be in a subdirectory
>>>> named "levenshtein". So for every directory in yoru CLASSPATH, it's
>>>> looking for a subdirectory named levenshtein that contains a
Difference
>>>> class.
>>>>
>>>> In the above example, if the CLASSPATH is /java/publicclasses then
your
>>>> code is looking for a file in the IFS named
>>>> /java/publicclasses/levenshtein/Difference.class -- because of the
way
>>>> you coded it, it's looking for a levenshtein/Difference.class in all
of
>>>> your CLASSPATH directories.
>>>>
>>>>
>>>> Nick Arndt wrote:
>>>>
>>>> >>>>> 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;
>>>>> }
>>>>> }
>>>>>
>>>>> >>>> --
>>>> This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing
>>>> >> list
>> >>>> To post a message email: RPG400-L@xxxxxxxxxxxx
>>>> To subscribe, unsubscribe, or change list options,
>>>> visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
>>>> or email: RPG400-L-request@xxxxxxxxxxxx
>>>> Before posting, please take a moment to review the archives
>>>> at http://archive.midrange.com/rpg400-l.
>>>>
>>>>
>>>>
>>>> >> --
>> This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing
list
>> To post a message email: RPG400-L@xxxxxxxxxxxx
>> To subscribe, unsubscribe, or change list options,
>> visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
>> or email: RPG400-L-request@xxxxxxxxxxxx
>> Before posting, please take a moment to review the archives
>> at http://archive.midrange.com/rpg400-l.
>>
>>
>> --
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.

This transmission may contain information that is privileged, confidential
and/or exempt from disclosure under applicable law. If you are not the
intended recipient, you are hereby notified that any disclosure, copying,
distribution, or use of the information contained herein (including any
reliance thereon) is STRICTLY PROHIBITED. If you received this
transmission in error, please immediately contact the sender and destroy
the material in its entirety, whether in electronic or hard copy format.
Thank you.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.