How to use Groovy Shell in Java9+?

已回答

This error is encountered when starting Groovy Shell:

`CommandLineWrapper` is ill-suited for launching apps on Java 9+.
If the run configuration uses "classpath file", please change it to "@argfile".
Otherwise, please contact support.

The solution given above is to change the ‘run configuration’, and after querying it, I learned that the option should be ‘Shorten command line’, but no similar option is found in Groovy’s run configuration.

1

What is the version of IntelliJ IDEA? That should have been fixed in 2020.3: https://youtrack.jetbrains.com/issue/IDEA-246923

There is no option for shorten command line, it is available for the Application type of Run Configuration only: https://i.imgur.com/mzUWdmI.png

1
Avatar
Permanently deleted user

@Konstantin Annikov

I'm using the 2021 version.

IntelliJ IDEA 2021.1.1 (Ultimate Edition)
Build #IU-211.7142.45, built on April 30, 2021
Runtime version: 11.0.10+9-b1341.41 amd64
VM: Dynamic Code Evolution 64-Bit Server VM by JetBrains s.r.o.
Windows 10 10.0

0

Please share a aproject sample where this could be reproduced. 

0
Avatar
Permanently deleted user

The problem still exists after upgrading to IntelliJ IDEA 2021.1.3.

0
Avatar
Permanently deleted user
0

This error is kind of expected because if groovy-xml jar is in the classpath, then one should have jaxb in the classpath as well.

Workaround is to set project SDK to Java 1.8

 
0
Avatar
Permanently deleted user

OK, it can be used temporarily.

But will this function stay in Java 1.8 forever?

Is there a plan for improvement?

0

Just add jaxb in the classpath to make it work with Java >1.8. 

0

Konstantin Annikov I know this is an old topic, but this just reared its ugly head for me. Add jaxb to which classpath? Where do I find that?

I love the Groovy console. It's so handy for quick tests. Would really like to get it working again.

IntelliJ IDEA 2023.2.1 (Ultimate Edition)
Build #IU-232.9559.62, built on August 22, 2023

 

Thanks!
 

0

Hi Jeffrey Verdegan Could you clarify a bit more details about the problem? A couple of screenshots and a project sample would help to fully understand your case. Files can be uploaded at https://uploads.jetbrains.com (do not forget to specify the UploadID)

The `Groovy Shell` action was removed a couple of releases ago and doesn't exist in the 2023.2.1 IDE build  so it is likely that you experience a different problem related to Groovy Console specifically 

I couldn't reproduce this problem in Groovy Console using openjdk-20 and a simple Groovy script

1

Hi, Egor,

I found a fix, 

Vanilla SDK for the module works, while IJ SDK does not, although both end up launching the same vanilla JVM, just with different args.

I created a brand new dummy project to reproduce the problem, and, of course, it didn't reproduce the problem. So I looked a little closer.

 

Dummy project | Settings | Modules | Module SDK -→ SDK 17 (default Java on my Windows laptop).

In Groovy Console I enter println 1 and hit go. It works.

"C:\Program Files\Java\jdk-17\bin\java.exe" "-Dgroovy.home=C:\Program Files\JetBrains\IntelliJ IDEA 2023.1.2" -Dfile.encoding=UTF-8 @C:\Users\jverdegan\AppData\Local\Temp\idea_arg_file46330056 org.codehaus.groovy.tools.GroovyStarter --main groovy.ui.GroovyMain -p "C:\Program Files\JetBrains\IntelliJ IDEA 2023.1.2\plugins\Groovy\lib\console.groovy"
> println 1
1

 

Actual “Broken” project | Settings | Modules | Module SDK -→ IntelliJ IDEA IU-211.7142.45.

Same Groovy Console actions. I get the error as expected.

"C:\Program Files\Java\jdk-17\bin\java.exe" "-Dgroovy.home=C:\Program Files\JetBrains\IntelliJ IDEA 2023.1.2" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\JetBrains\IntelliJ IDEA 2023.1.2\lib\idea_rt.jar" com.intellij.rt.execution.CommandLineWrapper C:\Users\jverdegan\AppData\Local\Temp\idea_classpath439893875 org.codehaus.groovy.tools.GroovyStarter --main groovy.ui.GroovyMain -p "C:\Program Files\JetBrains\IntelliJ IDEA 2023.1.2\plugins\Groovy\lib\console.groovy"
> println 1
`CommandLineWrapper` is ill-suited for launching apps on Java 9+.
If the run configuration uses "classpath file", please change it to "@argfile".
Otherwise, please contact support.

 

But then when I switch my real project over to the vanilla SDK, it also works fine.

I'll leave it to you guys to figure out if this is a bug with the IJ SDK or how it's used here, or if it's expected behavior. Either way, I got my Groovy back, so thanks!

--Jeff

0

I guess the 
@C:\Users\jverdegan\AppData\Local\Temp\idea_arg_file46330056
vs. 
-classpath "C:\Program Files\JetBrains\IntelliJ IDEA 2023.1.2\lib\idea_rt.jar"
is exactly what the error message was talking about.

0
Avatar
Margarita Tyumenkova

Hello Jeffrey Verdegan,

I created bug in YouTrack: IDEA-332145

1

请先登录再写评论。