Steve,

I do not think you should exec the java program with the name of the class 
library as the call parameter. Instead, the library "HelloWorld.class" 
will contain one class with a main-function (method as java folks say) and 
may be other classes. Ask the provider of the class library about this 
class name. The class name is to be passed to the java program for 
execution. For example:

file /u/USERID/Hello.java:
class MAIN {
   public static void main(String args[]) {
     .... do something like System.out.println("Hello World");....
   }
}

Then compile the source to the class-file:
javac /u/USERID/Hello.java 
will result in /u/USERID/Hello.class
(May be you need a couple of extra parameters for this to happen 
correctly.)

These two steps are done from the development team. They will tell you 
about the name of the "main" class.

Then run the class with java -cp /u/USERID MAIN

Like the "-cp" parameter you can provide various other parameters to tune 
the java program's behaviour. One of those is -Dfile.encoding=whatever. 
For JZOS, these parameters are defined in the symbol IBM_JAVA_OPTIONS.

Cheers 
Michael




Steve Comstock <st...@trainersfriend.com> 
Gesendet von: IBM Mainframe Discussion List <IBM-MAIN@BAMA.UA.EDU>
06.10.2009 14:09
Bitte antworten an
IBM Mainframe Discussion List <IBM-MAIN@BAMA.UA.EDU>


An
IBM-MAIN@BAMA.UA.EDU
Kopie

Thema
Deeper java problem






Replying to my first post about a Java compile
program, several people suggested it was a
codepage issue. And that was my first thought,
too, since I had been experimenting with
various code pages in my emulator.

However, with codepages matching in both the
old and the new system, I cut and pasted from
the old to the new and reran the compile. Same
result.

Michael Klaeschen suggested I check file.encoding
and the symbol IBM_JAVA_OPTIONS, but I can't find
those. I'm just issuing the javac command directly
under omvs.

More disturbing, I did a cd to the JAVA_HOME directory:

cd /u/Java6_31/J6.0

And an 'ls' showed:

-rw-r--r--   1 TCPIP    IPGROUP      425 Jun  3 22:39 HelloWorld.class
drwxr-xr-x   2 TCPIP    IPGROUP     8192 Mar 14  2008 IBM
-rw-r--r--   1 TCPIP    IPGROUP        6 Jun  3 22:39 JDK_INSTALL_OK
drwxr-xr-x   4 TCPIP    IPGROUP     8192 Jun  3 22:39 bin
-rw-r--r--   1 TCPIP    IPGROUP      833 Mar 22  2009 copyright
drwxr-xr-x  13 TCPIP    IPGROUP     8192 Jun  3 22:36 demo
drwxr-xr-x  16 TCPIP    IPGROUP     8192 Jun  3 22:39 docs
drwxr-xr-x   3 TCPIP    IPGROUP     8192 Jun  3 22:36 include
drwxr-xr-x  13 TCPIP    IPGROUP     8192 Jun  3 22:35 lib
-rw-r--r--   1 TCPIP    IPGROUP    44534 Jun  3 22:39 license_en.txt
drwxr-xr-x   3 TCPIP    IPGROUP     8192 Jun  3 22:37 mvstools
-rw-r--r--   1 TCPIP    IPGROUP    36370 Jun  3 22:40 notices.txt
-rw-r--r--   1 TCPIP    IPGROUP     1694 May 29 09:41 readmefirst.zos.txt
-rw-r--r--   1 TCPIP    IPGROUP  9084677 Jun  3 22:19 src.zip
drwxr-xr-x   5 TCPIP    IPGROUP     8192 Jun  3 22:40 standard

But when I tried to run the sample, here is what I got:

java HelloWorld.class
Exception in thread "main" java.lang.NoClassDefFoundError: 
HelloWorld.class
Caused by: java.lang.ClassNotFoundException: HelloWorld.class
         at java.net.URLClassLoader.findClass(URLClassLoader.java:419)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:643)
         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:345)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:609)
Could not find the main class: HelloWorld.class.  Program will exit.

just to be sure, I looked at PATH and CLASSPATH:

printenv PATH
/u/Java6_31/J6.0/bin:/usr/lpp/pli/bin:/usr/lpp/internet/bin:/usr/lpp/cobol/bin:/bin:.
 



printenv CLASSPATH
/u/scomsto/CGI:/u/scomsto/public_html/Java:/usr/lpp/internet/server_root/cgi-bin:/u/Java6_31/J6.0:/u/Java6_31/J6.0/src.zip:.
 



In both cases, the '.' at the end should ensure a search
in the current working directory. And I was running in
the JAVA_HOME directory. And I can see the class right
there before me.

Any suggestions at this point?


-- 

Kind regards,

-Steve Comstock
The Trainer's Friend, Inc.

303-393-8716
http://www.trainersfriend.com

   z/OS Application development made easier
     * Our classes include
        + How things work
        + Programming examples with realistic applications
        + Starter / skeleton code
        + Complete working programs
        + Useful utilities and subroutines
        + Tips and techniques

==> Ask about being added to our opt-in list:              <==
==>   * Early announcement of new courses                  <==
==>   * Early announcement of new techincal papers         <==
==>   * Early announcement of new promotions               <==

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@bama.ua.edu with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@bama.ua.edu with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html

Reply via email to