Re: uploading VJ-built Java classes to Linux

by Bennett Haselton <bennett(at)peacefire.org>

 Date:  Sat, 04 Aug 2001 19:02:36 -0700
 To:  hwg-servers(at)hwg.org
 In-Reply-To:  speakeasy
  todo: View Thread, Original
*groan*... I figured it out... you have to type "java Class1" to run the 
Class1.class file, not "javac Class1.class".  "javac" is the utility for 
compiling .java files into .class files.  Virtually all Java developers 
probably know this, but I'd been learning from Microsoft Visual J++, which 
(surprise!) follows its own rules (jvc.exe for compiling .java files, and 
jview.exe for loading .class files, although Visual J++ usually hides this 
from you).

I also got confused because "javac Class1.class" produced what looked like 
a normal compiler or loader error:
java.lang.NoClassDefFoundError: antlr/collections/AST
[etc.]

Normally if you pass a binary file to a command-line compiler, it would 
barf so obviously that you'd know you were using the wrong tool for the 
wrong job :)

         -Bennett

At 04:25 PM 8/4/2001 -0700, Bennett Haselton wrote:
>I'm writing a CGI program in Java to be run on a Linux machine.  What is 
>the one thing you have to tweak in Visual J++ so that you can create Java 
>classes in VJ++ and have them work on a Linux command line?  I'm using 
>VJ++ to write it since I like the statement completion and other features 
>of the text editor.
>
>I created a new Visual J++ project of type "Console Application", and 
>modified the main function of the default Class1 class to print "3":
> >>>
>public class Class1
>{
>         /**
>         * The main entry point for the application.
>         *
>         * @param args Array of parameters passed to the application
>         * via the command line.
>         */
>         public static void main (String[] args)
>         {
>                 System.out.println(3);
>         }
>}
> >>>
>
>Building it in VJ++ produces a Class1.class file and a Project1.exe file 
>which outputs "3" when run on the command line.  But when I upload the 
>Class1.class file (in binary mode, of course) to the Linux server and run 
>"javac Class1.class" from there, I get:
> >>>
>server1:/home/bhaselto/web/html/tlnew$ javac Class1.class
>java.lang.NoClassDefFoundError: antlr/collections/AST
>         at at.dms.kjc.Main.beautifyParseError(Main.java:692)
>         at at.dms.kjc.Main.parseFile(Main.java:488)
>         at at.dms.kjc.Main.run(Main.java:119)
>         at at.dms.kjc.Main.compile(Main.java:449)
>         at at.dms.kjc.Main.main(Main.java:432)
> >>>
>
>My first thought was that this error must have been committed thousands of 
>times by people trying to do this before, so I did an Alta Vista search for
>         "java.lang.NoClassDefFoundError: antlr/collections/AST"
>hoping to find other pages discussing this problem.  This technique almost 
>always works for tracking down the cause of errors that have been seen 
>before by other people; this time, however, it produced nothing useful.
>
>Is this related to the controversy over Sun's charges that Microsoft 
>deliberately rigged VJ++ to create classes that could not be run on 
>non-Microsoft platforms?  Or is there something simple that I forgot to do?
>
>         -Bennett
>
>bennett(at)peacefire.org     http://www.peacefire.org
>(425) 649 9024
>


bennett(at)peacefire.org     http://www.peacefire.org
(425) 649 9024

HWG: hwg-servers mailing list archives, maintained by Webmasters @ IWA