question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Script with a main method is not run in kscript

See original GitHub issue

I’m using IntelliJ to write kotlin script. In order to make my script valid with IntelliJ inspections, I’m defining a standard main method. The problem is that when running my file from kscript, my main method is not run at all.

Is there a special action to run the main method from the command line ?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:14

github_iconTop GitHub Comments

1reaction
holgerbrandlcommented, Jun 21, 2017

Concerning the //ENTRY directive. Assuming the presence of a main method does not make sense imho because kotlin scripts don’t require a main and work fine without.

And since Kotlin is very flexible concerning how main can be defined in a kt source file, I’m not sure it’s intuitive to assume one particular type of main. E.g. another popular to define via a companion method:

class Foo{
    companion object {
        @JvmStatic fun main(args: Array<String>) {
            println("Hello World")
        }
    }
}

To detect the entry-point programmatically here would require quite some non-trivial logic.

0reactions
holgerbrandlcommented, Oct 20, 2017

fixed with v2.0.1. Feel welcome to comment on this ticket if you still struggle to run your code with that version.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Script with a main method is not run in kscript #31 - GitHub
I'm using IntelliJ to write kotlin script. In order to make my script valid with IntelliJ inspections, I'm defining a standard main method....
Read more >
Scripting with Kotlin - Kscript | craigrussell
Kscript offers not only a convenient way to run a script, ... You don't need a main method and you don't need to...
Read more >
Why does Katalon Studio not require a main method to ...
Why when programming in Java in Script View does the code not need a main method to execute? All katalon needs is a...
Read more >
JScript, C#Script and C++Script - Specifics of Usage
In TestComplete, if a script calls an object method that is defined in another unit, and this method throws an exception, the exception...
Read more >
kscript - JetBrains
How kscript provides enhanced scripting support for Kotlin. ... Use //ENTRY to run applications with main method kscript also supports running regular ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found