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.

How to pass command line parameters to the java compiler

See original GitHub issue

In my project we use spring data with named parameter, which is running fine with IntelliJ, but in VSCode I get the following exception:

2022-01-28 11:01:15,170 |-ERROR in at.***.commons.exception.RestExceptionHandler - For queries with named parameters you need to use provide names for method parameters. Use @Param for query method parameters, or when on Java 8+ use the javac flag -parameters.; nested exception is java.lang.IllegalStateException: For queries with named parameters you need to use provide names for method parameters. Use @Param for query method parameters, or when on Java 8+ use the javac flag -parameters.
org.springframework.dao.InvalidDataAccessApiUsageException: For queries with named parameters you need to use provide names for method parameters. Use @Param for query method parameters, or when on Java 8+ use the javac flag -parameters.; nested exception is java.lang.IllegalStateException: For queries with named parameters you need to use provide names for method parameters. Use @Param for query method parameters, or when on Java 8+ use the javac flag -parameters.
	at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:371)
EntityManagerFactoryUtils.java:371
	...

In IntelliJ I can set “Additional command line parameters” under Settings -> Build, Execution, Deployment -> Compiler -> Java Compiler. And this issue is solved, if I add “-parameters” as command line parameter in IntelliJ, but I have no clue how to do this in VSCode. I can only find information about passing vmarg parameters in VSCode.

Environment
  • Operating System: Win 10
  • JDK version: 11
  • Visual Studio Code version: 1.63.2
  • Java extension version: Language Support for Java™ by Red Hat v1.3.0
Steps To Reproduce

Use Spring Data with named parameters (Spring Docu Named Parameters) without the annotation @Param and the compiler flag “-parameters” is not #set.

Current Result
  • Can run the applications until the the application tries to access via spring data the database and then it throws the mentioned exception
  • Run & Debug Tests (e.g. Integration / Karate tests) not possible because of the mentioned excetpion
Expected Result
  • pass java compiler flags like “-parameters” should be possible
Additional Informations

#2269

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
chad-russellcommented, Feb 11, 2022

For those running into this in the future: I was able to solve it by adding this to my .prefs file (the one specified by the java.settings.url setting)

org.eclipse.jdt.core.compiler.codegen.methodParameters=generate
1reaction
slPerryRhodancommented, Feb 18, 2022

@snjeza I looked at it many times and it’s not helpful.

@chad-russell thanks, thats good. A bit (very) inconvenient to configure compared to eclipse and intelliJ, but at least it’s possible.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Command Line Arguments in Java - DigitalOcean
How to Pass Command Line Arguments in Eclipse ; Step 1: Open the Class Run Configurations Settings · Eclipse Run Configurations ; Step...
Read more >
Java Command Line Arguments - Javatpoint
Java Command Line Arguments with examples, passed from the console and ... You can pass N (1,2,3 and so on) numbers of arguments...
Read more >
Compiling and Running with Arguments - Learn Java Online
The main methods get an array of strings as an argument, these are the command line arguments you may pass to your program....
Read more >
Java Command Line Arguments With Examples - Edureka
The command-line arguments are passed to the program at run-time. Passing command-line arguments in a Java program is quite easy. They are ...
Read more >
Command Line Arguments in Java - YouTube
Java Programming: Command Line Arguments in Java ProgrammingTopics discussed:1. Command line arguments.2. Passing the arguments to our ...
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