From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-4324.protonmail.ch (mail-4324.protonmail.ch [185.70.43.24]) by sourceware.org (Postfix) with ESMTPS id E9C0B3858415 for ; Tue, 7 Sep 2021 10:16:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E9C0B3858415 Date: Tue, 07 Sep 2021 10:16:08 +0000 To: phiroc@free.fr From: spellcard199 Cc: kawa@sourceware.org Reply-To: spellcard199 Subject: Re: Main class can't be loaded Message-ID: In-Reply-To: <1198267183.186506390.1631002998103.JavaMail.root@zimbra65-e11.priv.proxad.net> References: <1198267183.186506390.1631002998103.JavaMail.root@zimbra65-e11.priv.proxad.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.2 required=5.0 tests=BAYES_00, BODY_8BITS, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, FREEMAIL_REPLYTO_END_DIGIT, KAM_SHORT, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=no 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 10:16:13 -0000 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