Skip to content

markdown runner can't find unnamed class's main #2575

Description

@sixcorners

The markdown runner can't invoke unnamed classes.

```java
void main() {
  System.out.println("Hello world!");
}
```

it says it can't find the main class.

$ jbang README.md 
[jbang] [ERROR] No main class deduced, specified nor found in a manifest nor jar
[jbang] Run with --verbose or -x for more details. The --verbose or -x must be placed before the jbang command. I.e. jbang --verbose run [...]
 jbang -x README.md 
[jbang] [ERROR] No main class deduced, specified nor found in a manifest nor jar
dev.jbang.cli.ExitException: No main class deduced, specified nor found in a manifest nor jar
	at dev.jbang.source.generators.JarCmdGenerator.generateCommandLineList(JarCmdGenerator.java:271)
	at dev.jbang.source.generators.BaseCmdGenerator.generate(BaseCmdGenerator.java:51)
	at dev.jbang.cli.Run.doCall(Run.java:110)
	at dev.jbang.cli.BaseCommand.execute(BaseCommand.java:134)
	at org.aesh.command.impl.operator.EndOperator.execute(EndOperator.java:41)
	at org.aesh.command.impl.Executions$ExecutionImpl.execute(Executions.java:239)
	at org.aesh.command.impl.AeshCommandRuntime.runExecutor(AeshCommandRuntime.java:222)
	at org.aesh.command.impl.AeshCommandRuntime.executeCommand(AeshCommandRuntime.java:175)
	at org.aesh.AeshRuntimeRunner.execute(AeshRuntimeRunner.java:160)
	at dev.jbang.Main.main(Main.java:46)

A workaround is to just put the statements.

```java
System.out.println("Hello world!");
```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions