From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp2-g21.free.fr (smtp2-g21.free.fr [IPv6:2a01:e0c:1:1599::11]) by sourceware.org (Postfix) with ESMTPS id 445113858415 for ; Tue, 7 Sep 2021 11:07:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 445113858415 Received: from zimbra65-e11.priv.proxad.net (unknown [172.20.243.215]) by smtp2-g21.free.fr (Postfix) with ESMTP id E36492003E8; Tue, 7 Sep 2021 13:07:42 +0200 (CEST) Date: Tue, 7 Sep 2021 13:07:40 +0200 (CEST) From: phiroc@free.fr To: spellcard199 Cc: kawa@sourceware.org Message-ID: <1674648781.187044478.1631012860850.JavaMail.root@zimbra65-e11.priv.proxad.net> In-Reply-To: Subject: Re: Main class can't be loaded MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [178.213.64.34] X-Mailer: Zimbra 7.2.0-GA2598 (ZimbraWebClient - FF3.0 (Win)/7.2.0-GA2598) X-Authenticated-User: phiroc@free.fr X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, BODY_8BITS, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: kawa@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Kawa mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Sep 2021 11:07:46 -0000 Very thorough explanation, spellcard199. Many thanks. Philippe ----- Mail original ----- De: "spellcard199" =C3=80: phiroc@free.fr Cc: kawa@sourceware.org Envoy=C3=A9: Mardi 7 Septembre 2021 12:16:08 Objet: Re: Main class can't be loaded Hello. First of all the java classpath needs both: - kawa.jar - your classes' directory So the java command becomes: java -cp "/path/to/kawa.jar:." mod1 If you try to run the above command it should give another error: Error: Main method not found in class mod1, please define the main method= as: public static void main(String[] args) or a JavaFX application class must extend javafx.application.Application To solve this recompile using the --main flag (https://www.gnu.org/software/kawa/Compiling.html): kawa --main -C mod1.scm Now it should work. P.S. Why we need kawa.jar in classpath: On my OS the full error was: Error: Could not find or load main class mod1 Caused by: java.lang.NoClassDefFoundError: gnu/expr/RunnableModule gnu.expr.RunnableModule is a class in the Kawa codebase. The output of javap on mod1.class is: public class mod1 extends gnu.expr.ModuleBody implements java.lang.Runnab= le,gnu.expr.RunnableModule { public static mod1 $instance; public final void run(gnu.mapping.CallContext); public static {}; public mod1(); public static void main(java.lang.String[]); } You can see that this java code depends on several classes defined in Kawa: - gnu.expr.ModuleBody - gnu.expr.RunnableModule - gnu.mapping.CallContext =E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90 Original Me= ssage =E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90 On Tuesday, September 7th, 2021 at 10:23 AM, phiroc--- via Kawa wrote: > Hello, > > Let's say a file called mod1.scm contains the following definition: > > (define (fun1 x y) > > (list x y)) > > ...and has been compiled to a Java class, thus: > > kawa -C mod1.scm > > Why does the following message appear when you run the class? > > "the main class can't be loaded" > > java -cp . mod1 > > Many thanks. > > Phil