public inbox for
 help / color / mirror / Atom feed
From: spellcard199 <>
Subject: Re: Main class can't be loaded
Date: Tue, 07 Sep 2021 10:16:08 +0000	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

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

  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.Runnable,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

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

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

  reply	other threads:[~2021-09-07 10:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <>
2021-09-07  8:23 ` phiroc
2021-09-07 10:16   ` spellcard199 [this message]
2021-09-07 11:07     ` phiroc

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='' \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).