I'm trying run package org.testfx in my JavaFX application, but i'm a facing error "JavaFX.graphics is not accessible". So I'm trying put vmArgs in VsCode tests to exports javafx.graphics, but not sucessfuly, one help?
My Code:
"java.test.config":
{
"name": "testConfig",
"workingDirectory": "${workspaceFolder}",
"vmArgs": ["--add-exports javafx.graphics/com.sun.javafx.application=ALL-UNNAMED"]
}
Well... I resolved the problem, but not the way I expected.
Resolution
I removed the module-info.java to have no problem with access modules, apparently have just this option, so I have other problem, but nothing that interrupts my application.
the problem: WARNING: Unsupported JavaFX configuration: classes were loaded from 'unnamed module #4f10c7de'.
I resolved this with put vmArgs in launch.json on vscode:
"--module-path \"location-javafx\\lib\" --add-modules javafx.controls,javafx.graphics,javafx.fxml".
What I wanted?
I want to make a test automatized with org.testfx, for test all process my application and minimize bugs.
To persons who have this problem, if that way don't working for you, try these links:
StackOverflow
JavaFX WARNING: Unsupported JavaFX configuration: classes were loaded from 'unnamed module #...'
JavaFX project wrapped with Launch4j VM arguments path
IllegalAccessError when trying to use TestFX caused by module-info.java file
VSCode's site and GitHub
VSCode java Testing
OpenJFX 11 compatibility issue
If anyone can find another answer, please share with me, please.
Related
MY SETUP:
I followed the steps for the JavaFX and IntelliJ -> Modular from IDE path.
I added the ikonli-core-12.2.0.jar, ikonli-javafx-12.2.0.jar and ikonli-carbonicons-pack-12.2.0.jar via the repository to the Scene Builder in this order. Here, they work fine.
Then I added those same .jars in that same order to the IntelliJ as described here: Correct way to add external jars (lib/*.jar) to an IntelliJ IDEA project.
My module-info.java file contains the following code:
module project {
requires javafx.controls;
requires javafx.fxml;
requires org.kordamp.ikonli.core;
requires org.kordamp.ikonli.javafx;
requires org.kordamp.ikonli.carbonicons;
opens com.project to javafx.fxml;
exports com.project;
}
Picture of my libraries:
PROBLEM:
When I add an icon to the .fxml file and I click on Run, I get the following error:
Error occurred during initialization of boot layer
java.lang.module.FindException: Module org.kordamp.ikonli.javafx not found, required by project
The module name varies. Sometimes it says it's the javafx, others the core or the carbonicons.
I'm not sure why this happens. When I'm typing in the module-info.java file I get the autofill prompts, , but when I try, for example, import org.kordamp.ikonli.core; in my Main.java, it doesn't detect them.
I'm not sure why this happens. When I'm typing in the module-info.java file or try import org.kordamp.ikonli.javafx.FontIcon; in my Main.java, I get the autofill prompts, so it means it's detecting them.
If I remove the "ikonli requires" from the module-info.java and run it, I get this error (which is kind of understandable):
java.lang.ClassNotFoundException: org.kordamp.ikonli.javafx.FontIcon
SOLUTIONS I'VE TRIED:
Adding the .jars via File -> Project Settings -> Libraries.
This seems to automatically add them to the Modules -> Dependencies, but even so, the problem persists.
Adding them in the VM Options (Run -> Edit Configuration -> Modify Options -> VM Options) in various ways, right after the --module-path ${PATH_TO_FX}:out/production mentioned in the steps linked above (out can be safely changed to mods but I chose not to do that).
First:
--module-path ${PATH_TO_IKONLI_CORE}, --module-path ${PATH_TO_IKONLI_JAVAFX} and --module-path ${PATH_TO_IKONLI_CARBONICONS}
Doing this makes it so my actual project module doesn't get detected. I.E. I get this error:
Error occurred during initialization of boot layer
java.lang.module.FindException: Module project not found
Second:
--add-modules ${PATH_TO_IKONLI_CORE},${PATH_TO_IKONLI_JAVAFX},${PATH_TO_IKONLI_CARBONICONS}
This one produces a smiliar error:
Error occurred during initialization of boot layer
java.lang.module.FindException: Module /directory/path/to/file/ikonli-core-12.2.0.jar not found
Third:
--add-modules org.kordamp.ikonli.core,org.kordamp.ikonli.javafx,org.kordamp.ikonli.carbonicons
A similar error shows up:
Error occurred during initialization of boot layer
java.lang.module.FindException: Module org.kordamp.ikonli.core not found
I tried File -> Reload all from disk and Invalidate Caches / Restart options, but they seem to have had no effect.
I created a lib folder in my src project folder, put the .jars there and added them as dependencies. Now they didn't show up in the External Libraries section (because they're not external obviously) but the problem remains (I'll re-add them as external again).
ADDITIONAL INFORMATION:
I've added controlsfx.jar the same way as the Ikonli .jars. The same error occurs for it as well.
They all have their module-info.class file in the proper directory as stated in the official javadoc, yet the ModuleFinder still throws the exception.
I've also checked my project.iml file and they all have the module-libraries with the correct directories present.
I've revisted the official Ikonli installation steps multiple times and everything checks out.
Though, in there it mentions that I need to have requires javafx.base; requires javafx.graphics; in the module descriptor. Not true, at least in my case, because when I add --show-module-resolution to the VM Options, it shows that they're loaded fine, but even when I do add them, the error still appears.
END
Sorry for the long post, I'm out of ideas and I don't know what else to try.
One of the comments here mentioned that they'd put their .jar in the mods/production folder. I did the same... and it worked. (╯°□°)╯︵ ┻━┻
I guess "Modular from IDE" doesn't agree with the IDE.
Looks like the proper way to go about modular is to use Maven/Gradle. I'll rebuild and go with Gradle.
Trying to move from Java 8 to Java 9, and I get this error
Package 'com.sun.webkit.dom' is declared in module 'javafx.web', which
does not export it to module.
How do I fix this so that the Pre-compiler (Intellij) and run-time that I don't get this or what is a good replacement for com.sun.webkit.dom.HTMLDocumentImpl.
Add
--add-exports javafx.web/com.sun.webkit=ALL-UNAMED
To your VM options or Gradle.
I tried this, but it didn't work for me. I tried various things and looked around. https://nipafx.dev/five-command-line-options-hack-java-module-system/ was helpful in understanding more about modules. In the end, running on intellij, adding this got it to work:
--add-exports javafx.web/com.sun.webkit.dom=ALL-UNNAMED
I had to explicitly include the full package.
I'm new to micro bench-marking in general. When I execute the JMH task in my project I get "ERROR: Unable to find the resource: /META-INF/BenchmarkList", I believe is created by jmh-generator-annprocess. I am using Gradle and I am trying to figure out if jmh-generator-annprocess is even working? Will it work properly for Gradle or do I need to use the Maven plugin or something?
https://github.com/coderrick/JMH-Studies.git in case you want to git clone my project and run it yourself.
There was a couple of issues
JMHSample_02_BenchmarkModes class was in incorrectly named java class
build.gradle was missing apply plugin: "me.champeau.gradle.jmh" declaration
In jmhJar section Main-Class manifest entry was overridden (which is unnecessary)
I've made a PR with above fixes. After applying it you can run performance tests using
java -jar build/libs/JMH-Studies-jmh.jar
I'm using gwt-maven-plugin to manage a GWT project. I use the gwt:run goal all the time to run locally in "dev mode" for testing. I now want to compile my project into a war for deployment on Tomcat. When I run gwt:compile, however, I get compile errors that indicate a classpath configuration issue. An example:
Finding entry point classes
[ERROR] Errors in 'shared.MyClass.java'
[ERROR] Line 4: The import server.model.MyObject cannot be resolved
Any ideas? Do I need to manually add the server package to some config file somewhere? Thanks in advance for any info.
-tjw
Ok, I found the problem. I found this in the GWT forums by Thomas Broyer (a GWT dev):
I mean you have to "javac" classes that are referenced from
annotations (in this case, the PlaceTokenizer classes referenced from
#WithTokenizers; that'd be true also of your service, domain object,
locator or service locator with RequestFactory, unless you use
#ServiceName and #ProxyForName). Otherwise, GWT can work with only
the *.java files, without the *.class.
I am trying to load in these classes from annotations since they are used with RequestFactory. My question is now this: How is this restriction not completely insane?
I am building an Android hello world application in Netbeans. It's building properly and I am able to run in the emulator also.
But when creating and running the Junit test I get a java.lang.NoClassDefFoundError.
How can I fix this problem?
Check the manifest of your test project, for example HelloWorldTest/AndroidManifest.xml. The android:targetPackage attribute of the instrumentation markup should target the package in your application, for example, com.example.helloworld. Not the test package of your test project (eg. com.example.helloworld.test).
Simply AndroidManifest.xml -> manifest -> package of main application should match AndroidManifest.xml -> manifest -> instrumentation -> android:targetPackage of the test application.
The full error message contains the name of the class, that wasn't found on the classpath. Double check if the classpath that is used for running the test includes all required classes and libraries (your class files, junit.jar, android specific libaries).
I find that a rebuild usually finds the classes (as it is a classpath issue). Netbeans seems to aggressively compile existing tests, but the main source code (from a maven setting at least) is not always available.
I've started running full builds to try address this. There might be a plugin that addresses this but I haven't found it yet.
EDIT: This might help.
I don't know about netbeans specifics, but the problem is probably the same.
FragmentActivity can not be tested via ActivityInstrumentationTestCase2
Your test project can be using a different android compatibility library than your main project, and that causes this weird errors.