× 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.




Hi James,

As David mentioned, first make sure you're using binary mode for FTP. That's just a checkoff item.

If so, look at the error message: java.lang.UnsupportedClassVersionError

At JDK 1.5, changes were made to the binary format and previous JVM's won't run the program. That's what it sounds like. Run java -version ( actually JAVA *VERSION on the AS/400 ) to see what version you're using. If below 1.5, you'll need to recompile with a pre 1.5 version or make sure you're running a 1.5+ version.

As to the java.lang.NoClassDefFoundError, looks like you gave it the classpath to the version of the JVM you're expecting, but not to the class you are running. This is a major reason I always ask, why do you have multiple Java installations? because the system defaults to sometimes unexpected versions. If only one is installed, that's what it will use.

And, to others, yes I'm aware that at least some versions of WebSphere ( and possibly other programs ) insist on specific versions. Poor ( or predatory ) programming practice IMO. Yet another reason I recommend running Java on another box and use JTOpen for AS/400 operations.


Joe Sam

Joe Sam Shirah - www.conceptgo.com (904) 302-6870
conceptGO - Consulting/Development/Outsourcing
Java Filter Forum: www.ibm.com/developerworks/java/
Just the JDBC FAQs: www.jguru.com/faq/JDBC
Going International? www.jguru.com/faq/I18N
Que Java400? www.jguru.com/faq/Java400



-----Original Message----- From: James Lampert
Sent: Monday, June 18, 2012 2:51 PM
To: Java Programming on and around the IBM i
Subject: Simple test Java app runs fine under Eclipse, and from a WinDozecommand line, but fails on the 400.

I have a simple Java 6 test program, just one class:

import java.nio.charset.*;
public class Test18jn2012 {
public static void main(String[] args) {
String str = "I like Spam.";
byte[] bytes;
bytes = str.getBytes(Charset.defaultCharset());
for (int i=0; i < bytes.length; i++) System.out.print(bytes[i] + "
"); System.out.println();
}
}

It executes just fine in Eclipse. It executes just fine on a WinDoze
command line, even if I move it to a different directory from where I'd
compiled it into.

But when I FTP Test18jn2012.class to the IFS root on our 400, and I try
java Test18jn2012
from either a regular command line or a QShell command line, I get:
Exception in thread "main" java.lang.UnsupportedClassVersionError: (Test18jn2012) bad major version at offset=6
at java.lang.ClassLoader.defineClassImpl(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:267)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:151)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:600)
at java.net.URLClassLoader.access$400(URLClassLoader.java:124)
at java.net.URLClassLoader$ClassFinder.run(URLClassLoader.java:1055)
at java.security.AccessController.doPrivileged(AccessController.java:274)
at java.net.URLClassLoader.findClass(URLClassLoader.java:492)
at java.lang.ClassLoader.loadClass(ClassLoader.java:640)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:606)
Java program completed with exit code 1

and if I try
JAVA CLASS(Test18jn2012) CLASSPATH('/qibm/ProdData/Java400/jdk6')
I get
Exception in thread "main" java.lang.NoClassDefFoundError: Test18jn2012
Caused by: java.lang.ClassNotFoundException: Test18jn2012
at java.net.URLClassLoader.findClass(URLClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:640)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:606)
Java program completed with exit code 1

I'm obviously doing something wrong, but WHAT?

--
JHHL

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.