How to add --add-opens command to Jenkins - java

Environment:
Intellij
JDK 17
Maven
When i run my project i faced this error: Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private final java.util.Map sun.reflect.annotation.AnnotationInvocationHandler.memberValues accessible: module java.base does not "opens sun.reflect.annotation" to unnamed module #68267da0
Code:
enter image description here
f.setAccessible(true); this line throws the error
solution is to add this line JAVA_TOOL_OPTIONS=--add-opens=java.base/sun.reflect.annotation=ALL-UNNAMED
to the runner configuration at Intellij see the photo: enter image description here and it works
but now i need to pass this line JAVA_TOOL_OPTIONS=--add-opens=java.base/sun.reflect.annotation=ALL-UNNAMED to the Jenkins job
as i run my project through Jenkins so need to pass this solution to it
so how to do it?

At jenkins home page click Manage Jenkins link.
Click on the Global Tool Configuration link.
Go to JDK section and click Add JDK button.
Fill the Name field , Add the name of the JDK.
Add the JAVA_HOME path for JDK installation directory.
In the Java Options field, enter the "--add-opens" command.
Example -> --add-opens java.base/java.lang=ALL-UNNAMED
Finally click save button.

Related

Error adding module to project: illegal char :> at index 23

I tried to make a new project on IntelliJ IDEA. On the gradle options, I check the Java and Kotlin/JVM libraries. After I named the project folder, there's error popped up on my screen. I use jdk 16.
Error Adding Module
What's wrong with my jdk? anyone could help me?
I changed the environment variables of "JAVA_HOME" to be more specific. It didn't do it, if it's located on "C:\Program Files\Java". It'll do it if it's changed into "C:\Program Files\Java\jdk-16.0.2".

Error after generating Javadoc for my project in eclipse

After I generated javadoc for my project on eclipse, the following error messages pop up on the console.
Does anyone has a solution to my problem. I tried to include de modules that are missing in the VM options during the wizards but it still doesn't work.
Thanks
EDIT: I fixed it. First I deleted my module file, then I created the javadoc. After doing that, I configured my module file again and it worked
screenshot of errors
Your mistake have nothing to do with the Javadoc.
You've got an error because you use JavaFX and you haven't load the dependencies in the classpath.
To resolve your problem :
Near the run button you have a arrow. Click on it.
You will have a menu, then click on "run configurations..."
A pop up will open.
Then find the name of your main class in the list on the left of the pop up.
Then go in arguments section
And in the field named "VM arguments" write :
--module-path pathToJavaFXJDK/lib --add-modules:javafx.controls,javafx.fxml
replace pathToJavaFXJDK by the absolute path of your JavaFX directory.

How to tell eclipse to add-exports when compiling

Is it possible to tell eclipse to add the following command line option:
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
when compiling.
I think it may also be needed when running tests.
Is it also possible to remove this message:
Note that I tried to add those to the VM options of one of my unit tests but that did not work.
Go to Project > Properties: Java Build Path, tab Libraries
Select the JRE > Is modular node and click Edit...
Go to the tab Details
In the Added exports section click Add...
Enter the following:
Source module: jdk.compiler
Package: com.sun.tools.javac.tree
You can add the --add-exports jdk.compiler/.... options on VM Arguments as shown below.

How to run javafx applications in intellij idea IDE

I am trying to run JavaFX application but there is showing the following error
Error: JavaFX runtime components are missing, and are required to run this application
Until this step, I could not import the JavaFX, and I have done it from /usr/lib/jvm/java-8-openjdk-amd64
Can someone help to solve this error?
Thanks beforehand.
By the way, I am using lubuntu operating system
extra information
As explained on official OpenJFX website
open your intellij idea IDE and create new Project
Go to File > Project Structure
Go to Project Settings > Libraries
Click on + button
Locate ..\openjfx-11.0.1_windows-x64_bin-sdk\javafx-sdk-11.0.1\lib folder from extracted zip of openJFX 11
Apply settings and click ok
Go to File > Settings
In Settings go to Appearance & Behavior > System Settings > Path Variables
Click on + and add new path variable name it PATH_TO_FX and in value field locate ..\openjfx-11.0.1_windows-x64_bin-sdk\javafx-sdk-11.0.1\lib folder
Apply settings and click ok
The go to Run > Edit Configurations
Select your Application from Application > {your application name}
Then click on Configuration tab and in VM options field write this:
--module-path ${PATH_TO_FX} --add-modules=javafx.controls,javafx.fxml
Then Click on
Edit templates button select Application in Templates and again in VM options field write this:
--module-path ${PATH_TO_FX} --add-modules=javafx.controls,javafx.fxml
Apply settings and click ok and now you are good to go
You have to do this whenever you create new project in intellij
There is no strictly defined javafx in openjdk8.
You need to install openjfx via commandline:
sudo apt-get install openjfx

Error: Module not specified (IntelliJ IDEA)

I was trying to execute a simple program in IntelliJ IDEA as a static web project. I'm newbie and I'm learning web development with Node.js. I took help from the official website of IntelliJ IDEA, but the error was same. Though, I configured the settings and Project structure also.
Error:
"C:\Program Files\Java\jdk1.8.0_91\bin\java" -Didea.launcher.port=7535 "-Didea.launcher.bin.path=C:\Program Files\JetBrains\IntelliJ IDEA 2016.1.2\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\JetBrains\IntelliJ IDEA 2016.1.2\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain ""
Exception in thread "main" java.lang.ClassNotFoundException:
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:122)
Process finished with exit code 1
Snapshot of IDE
Please help me to sort out this problem. I'm digging out this problem since few days.
This is because the className value which you are passing as argument for forName(String className) method is not found or doesn't exists, or you a re passing the wrong value as the class name. Here is also a link which could help you.
1.
https://docs.oracle.com/javase/7/docs/api/java/lang/ClassNotFoundException.html
2.
https://docs.oracle.com/javase/7/docs/api/java/lang/Class.html#forName(java.lang.String)
Update
Module not specified
According to the snapshot you have provided this problem is because you have not determined the app module of your project, so I suggest you to choose the app module from configuration. For example:
this is how I fix this issue
1.open my project structure
2.click module
3.click plus button
4.click import moduleļ¼Œand find the module's pom
5.make sure you select the module you want to import,then next next finish:)
For IntelliJ IDEA 2019.3.4 (Ultimate Edition), the following worked for me:
Find the Environment variables for your project.
Specify, from the dropdowns, the values of "Use class path of module:" and "JRE" as in the attached screenshot.
I faced the exact issue of module not found and solved it by navigating to pom.xml file in file system of my project and opening it as a maven project in my intelliJIdea.
Then it has populated the sub modules for selection in the edit configurations window.
Faced the same issue. To solve it,
I had to download and install the latest version of gradle using the comand line. $ sdk install gradle using the package manager or $ brew install gradle for mac. You might need to first install brew if not yet.
Then I cleaned the project and restarted android studio and it worked.
This happened to me when I started to work with a colleque's project.
He was using jdk 12.0.2 .
If you are suspicious jdk difference might be the case (Your IDE complains about SDK, JDK etc.):
Download the appropriate jdk
Move new jdk to the folder of your choice. (I use C:\Program Files\Java)
On Intellij, click to the dropdown on top middle bar. Click Edit Configurations. Change jdk.
File -> Invalidate Caches and Restart.

Categories

Resources