Module Not Found, when doing "mvn clean install"
My project has one Module named useTesting and inside this module theres another 3 Modules (use-assembly, use-core, use-gui).
All these Modules do have a module-info.java
now I wanted to create another module named use-guiFX which is using things from use-core and use-gui
when calling mvn clean install I get the following:
what am I doing wrong?
I am using IntelliJ, Project is in Java and uses Maven.
can also join a call if needed.
771 Replies
⌛
This post has been reserved for your question.
Hey @Akif! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
Do you have a
use.gui
module with that name in the module-info.java?
Can you show the pom.xml and the module-info.java of use-guiFX
Can you try running
mvn clean verify -DskipTests
?
Does that succeed?
on the root projectIl run it now and let you know
on useTesting right?
on the root
I think that's
use
ah yeah ok wait
thats the root right?
If it's where all other modules are in
I guess I jut have had put a different name my fault
when like forking and cloning
Can you also show the pom.xml of use-gui?
Are you overwriting the normal JAR with a jar-with-dependencies?
Why are you using
in the maven-assembly-plugin?
this is the result of mvn clean verify -DskipTests
that part is copy pasted from the use-guis pom
[WARNING] Can't extract module name from use-gui.jar: Module 'use.core' is already on the module path!Yeah, I think the jar-with-dependencies is the issue Why are you using that anywhere?
the other poms have it like that so thats why
You can try removing the
<appendAssemblyId>false</appendAssemblyId>
from all POMsalright I will do that
and then the JARs with dependencies will have different names
I think so, what exactly do you mean when saying jar with dependencies?
You are using the Maven assembly plugin to generate JARs that include dependencies
I am trying to create the jar, which is a application that needs the librarys and such and the 3 modules to be also work with each other
meaning you'd have a single JAR that includes all dependencies/other modules it needs
which causes issues with (JPMS) modules
Because if you have a single JAR with everything, you don't have modules (module-info.java) any more
ahh
so I dont really need module-info.java?
originally that project does not have module-info.java build in
so you should not use a JAR with dependencies ;)
I just ended up building that in bcs when using webView (javaFX) it ended up causing problems when having created the jar
here is the original Project:
https://github.com/AkifAydin/useTesting
or I should say my fork of it
here is the original:
https://github.com/useocl/use
after having done this and calling "mvn clean install" now I get this:
ok it seems like that integration test requires a JAR with dependencies
yeah I would like to not change the project, like the way it was originally.
So my project, for you to understand what I am trying and working on is, that I am trying to migrate the GUI part of this application, which is originally swing/awt to javafx.
so it then motly worked in the IntelliJ Local Machine when calling it in there but when having created the Jar the for example webView caused problems which sayed something like module not found.
Would you say that my idea of building in the module-infos in the classes was maybe obsolete?
It seems like that was already fixed 4 months ago in the original project
but you don't have that change in your fork
you mean the changes in the pom.xmlof the use?
Changes to
ShellIT
that was the change: https://github.com/useocl/use/commit/398d22c3b0fe87bdb73369c75c1f342f58bca144#diff-6be402a6a12a05ccc68e82ef7eb82ac20909980f73fefa36a84faef304322b3dR2
GitHub
refactor: In process integration tests for the shell · useocl/use@3...
- Instead of executing the final binaries for the integration tests, which consumed a lot of time, we execute them in process by repeatedly calling main
- Minor code style fixes suggested by IntelliJ
or you could also try getting it to work without modules
would you say I can just upgrade this part of the code? Or I would need to upgrade more?
If possible, I'd just update everything
but make a backup of your project first
you should be able to just pull/merge it with git (after you have the backup)
how could I best do a backup?
kinda stressing a bit now :boohoo: 😅 like panicking prob for no reason but yeah sorry
I was thinking of just copy pasting the project file somewhere else but maybe thats not the best solution/Backup?
copy the project
it's fine
ok I will try
@dan1st I have a stupid question now, do I want the things from Master? or do i have to use origin?
From the master of the remote corresponding to the original repository
What's the output of
git remote
?origin
only that?
i never really worked with forked projects I am sorry
yes only that
I assume that's your fork?
idk i guess so 😅
mine is actually called akifAydin
the one I am using
https://github.com/AkifAydin/useTesting/tree/akifAydin
you can add a new remote to the original repo with
git remote add upstream <URL of the original repo>
this will create a new remote called upstreamah did I maybe do something wrong when forking?
What's the output of
git status
?
no, not at alland then shows things to be stashed and changes and such but I think you wanted to see that on top
Which changes are there?
no I'm interested in changes
changes to be commited not staged oned and untracked ones
so you changed a lot
I hope there won't be merge conflicts
idk I actually didnt change anything or anything at all
I motly just worked in that form me new created module
Then why are there so many modified files?
I got curious and am checking idk haha
might be line endings...
idk its showing me only the javadocs
but i didnt tach these files
so weird idk
oh you renamed a package
so yeah with this I connect now the original repo
you changed use.main to use.maincore
ah yeah that could be it
I did that a few times but I thought i changed it back
Did you commit it in between?
on my forked project only on akifAydin
yeah so you changed the package, committed and changed it back?
last time 2 weeks ago thought havent had big accomplishments since I had this problem caused by the mvn generated jar not being able to show me wevView and such
oh no these I didnt commit
thats all in this 2 weeks
then I think you didn't change that package back
now i have upstream I see
yeah but before pulling in the changes from there, you should probably make sure you have no conflicts if possible
and renaming a package iss very likely to cause conflicts
so you might want to change it back
I changed it back you was right
it was maincore
I think you might want to add
use-guiFX/target
to the gitignore
after doing that, run git add .
followed by git status
to see your current stateah ok so it doesnt show it anymore for now
What does that show?
sorry ignore the file before this
still quite a few changes in use-core that could cause issues
you can try to create a commit
and then run
git pull upstream
oh but I dont know if I want to commit these should I?
you could also just run
git pull upstream
and see whether it works
or first run git stash
which removes your changes, pull and then run git stash apply
to get your changes backgit pull upstream master
and hope there are no merge conflictsyeah causing an problem
as you guessed
that looks like many potential merge conflicts
you can do that:
-
git stash
- git pull upstream master
- git stash apply
and see which conflicts you get
if pulling gives you something about conflicts, don't do git stash applyhow can I check if it stashed?
git status
bcs the terminal was acting weird and now says no local changes to save
Did you run the stash command twice?
that looks like stashing was successful
I might have bcs of the terminal
ah ok glad to hear that
you can run
git pull upstream master
I did run it
oh no
ok only one merge conflict
as it seems
And it seems like it's an IntelliJ file
yeah right
Can you run
git status
?I can add that to ignore?
Does it show anything about
both modified
?yeah it does
on a few files
if you meant that
I think you can just run
git checkout --theirs .idea/misc.xml
to just use the misc.xml from the repo and ignore your changes to it
Can you check the file use-gui/src/main/java/org/tzi/use/gui/views/diagrams/classdiagram/ClassDiagram.java
?
I think it should have some weird markers indicating the conflicting parts
like <<<<<<<<, >>>>>>>>> and ========xD
Are these markers somewhere?
e.g. near imports
Did you modify that class in previous commits?
ok yeah this is where a merge conflict happened
i dont get it thought, bcs I have no changes in here since we stashed?
I think HEAD is your previous version and the part after the ====== is the changes from the original repo
The stashing temporarily removed all your changes
now you are merging the existing commits with the updates from the original repo (upstream)
ok so what would we do now?
fix all these conflicts
it seems like only a comment?
you see both versions and you have to decide on the version you want
so I could copy paste the part of the current in these?
you remove the version you don't want
or is there a more professional way on doing it?
?
I mean master/original
deciding for that*
Do you want all changes from the original repo/upstream and ignore your changes?
you mean the ones we stashed?
no
commits you made previously vs changes in the orriginal repository
the stashed things are gone until you take them back in which case you could have more merge conflicts
as I sayed I mainly commited things in that new Module I created
yeah you'll see about that later
i think these wouldnt be affected right?
no
should be fine
alright than i think we can do this
I just hope project isnt gonna explode ☠️ with more problems
but yeah we have a backup
if you want to ignore all changes in your previous commit, you can run
git checkout --theirs use-gui/src/main/java/org/tzi/use/gui/views/diagrams/classdiagram/ClassDiagram.java
and see whether that file still has errorsit looks like this
it did Update that little part which we did see
Do you have Java 21 installed?
Because the new version updated to Java 21
yeah exactly I think your right I need 21
bcs this updated
i am installing Amazon Coretto 21.0.5 now
the one IntelliJ recommends
ok
should be fine
I wounder if it causes problems with javafx
but will see
JavaFX should support that
yeah thats what I think
at least newer JavaFX versions
alright warnings gone I think
Does it look fine?
yes
just ClassDiagram is still red?
is it bcs that one had the conflict?
I mean the files color
Can you show it? I think it's just still marked as conflicting
You can run
git add use-gui/src/main/java/org/tzi/use/gui/views/diagrams/classdiagram/ClassDiagram.java
which means "I have resolved the merge conflict"ah I see wasnt just added
Can you run
git status
again?ok so you can do
git add .idea
to mark that conflict as resolved as well
and then run git commit
, to finish the mergepressing jut enter it was right?
press the ESC key followed by
:wq
meaning "write quit"
and then enterah ok ty
did so
great, the merge is finished
you see there are 67 commits you have that are not in your fork. These are the commits from the original repository that aren't in your fork
ahh I see
You can now run
git stash apply
. This should reapply all changes you stashed2 conflicts if I read correct
the classdiagram one and pom
ok now you can handle the merge conflicts
but you might want to do it manually
open the files
and then check for differences and edit it to whatever you prefer
well the 21 is the correct one
so like this you mean
exactly
anything else in the pom.xml?
regarding merge conflicts
nothing else in the pom
then you can use
git add pom.xml
to confirm you have resolved the conflicts in that fileI think you want both methods here maybe..?
yeah exactly
the bottom one is mine is just a flag I use
then keep both methods
but remove the conflict markers
you mean these <<< things right?
yes
But I think there are more conflicts in that file
that was the only one with <<<...
it seems there are still a few errors in the file
i think bcs I have to add these new things into the modules
the ones which came new and I dont have in the modules maybe
inside the module-info.javas i mean
Can you run
mvn compile
and see wwhat happens?do you know why sometimes when I copy things from the terminal they disappear or the terminal looks different afterwards?
that means Maven doesn't know about your Java 21 Installation
I don't use IntelliJ
and idk what you mean
even thought it shows it on the project structure on them all
ahhh
IntelliJ knows about Java 21 but not Maven
I have to maybe change my environmental variables?
you can do that or you can run Maven in a different way from IntelliJ
Do you have a Maven tab on the right in IntelliJ?
yes exactly
that popped up when we did all the git pulling
Can you use the reload icon?
?
I did now
ah lol
that fixed it
xD
if you expand use, is there a lifecycle thing?
nice
like all the red is gone
Are all errors gone?
yeah only adding class is left I guess
ClasDiagram*
?
I mean just like we added pom.xml
?
ah yes
and testing what works
I meant in the Maven tab
ah yes there is
sorry I never used it
if you expand it, does it have a "conpile" thing?
so classdiagram and pom is added now ✅
yes
Can you double-click it? That should try compiling the project with Maven
hopefully using JDK 21
couple modules not found
double-clicking compile there is similar to
mvn compile
ah I see
like when I do in the terminal mvn compile in the path of use
ok seems like there are some issues left there
yes
I will be back really quick need to go to the kitchen
Got Coffee :boohoo:
nice
under-caffeination subverted
does this happen bcs of using module-info.java?
yes
where is that?
I think that was original reason why i changed the names when I was creating these
this one in use-gui
its so funny how I take one and destroy another haha
yeah if you have modules, you cannot use the same package in different modules
so I would need to change package names
How many classes are in the same package in both modules?
wow idk too many haha
here is the tree
its a lot
I was thinking of renaming the folders but maybe thats not a good idea?
How many files are in that package in use-gui?
subpackages are not a problem
can I somehow get it also in the terminal like the tree with tree?
idk
but just check in IntelliJ
How many files are in the main package?
oh you mean this?
like directly in main?
no
ups sorry you did say files
wait I check
org.tzi.use.main
files in that package
not including subpackages
so has 333 files and 49 folders
the
use-gui/src/main
I meant only the files in use-gui/src/main/java/org/tzi/use/main without subfolders
ah that one
that has 9 files
what do you mean without subfolders?
ok then you should hopefully be able to just move that 9 files to a new subpackage
not including files in subfolders if there are any
so shell i wouldnt count
than its 1 file?
e.g. move them to use-gui/src/main/java/org/tzi/use/main/gui or whatever- just make sure the package doesn't exist elsewhere
even better
then you only need to move that file
but move it in IntelliJ
I feel like as if you are seeing my screan
since i was in the file directory I was legit about to do it there xD
and thought if it would cause problems haha
So this is how I would fix that "problem" by just moving the files into for example another file like in this case
it wouldn't cause many issues, you'd just have to change the package name
instead of creating new files so i can also jt rename files right?
?
like for example this one
I could jut rename input to inputShell
yes but it would also affect subfolders
if applicable
ah and thats where problems could happen?
merge conflicts if you merge again in the future
ah I get it
so jut creating a new subfolder if its possible is best
if you change a package name, you might have conflicts in all the files in that package
a subfolder doesn't solve the issue but it doesn't affect other packages in the same directory
it's just minimizing possible impact
you know what i do with the errors like this one:
[INFO] use 7.1.1 .......................................... SUCCESS [ 0.003 s]
[INFO] use-assembly 7.1.1 ................................. SUCCESS [ 0.001 s]
where it says that it doesnt exist?
never mind
I think its not being used anymore
I think you moved it but it didn't change the import
and thats why
or that
I think we are getting closer to maven not failing anymore
now its just that both read something similar
use.guiFX and use.gui for example vtd.xml
Do you still have the <appendAssemblyId>false?
in any pom.xml
i think I deleted all but Il check
all gone
like I deleted all I mean*
Does the package
org.tzi.use.gui.main
exist in both use-gui and use-guiFX?
deleted them now or before?like when you told me I deleted them
they are not there anymore in the poms
try running mvn clean compile
or clean followed by compile
yeah I mean since there was no module-info.java at all they all kinda have same foulder structures
the same package shouldn't be used in two different modules
not my project :x
I got to learn haha
well in guiFX, you can easily fix it
because you can move/rename stuff there without risking merge conflicts or similar
I wanted to change as less as possible in the other modules haha
but I guess I need to kinda do than
so now I would just change in guifx
so I can now jut change the main to mainFX for example?
refactor it*
well it might also be possible to get JavaFX to work without modules but it's annoying
yes
yeah It worked till I used javafx.webView
but yeah I wanted to try use it right way with module-info
and you probably needed
--add-modules
and whateversince thats how its supposed to be in javafx
yeah i did use them all in the vm options
checked alll in internet stack overflows and such haha
somehow nothing worked
yes the typical things
and I thought module-info would be simple solution
Man was I wrong
xD
it would be simple if the project didn't do stiff that doesn't work well with it
Exactly thats the problem
I mean tis a whole existing project
which is also old tbh
but yeah its also interesting
well does that work?
its running
he doesnt find packages and such again
guess have to just add these dependencies
Does mvn compile show an error?
yeah
looks about right
I think I just have to add these again
not accessible?
il do that really quick
tell me when you get a different error:)
mvn compile was succesfull 👀
but yeah mvn verify doesnt work 🤔
so yeah currently getting this one:
[ERROR] /C:/Users/akifn/Desktop/MyProjects/java/useTesting/use-gui/src/test/java/org/tzi/use/util/DiagramUtilTest.java:[20,1] Package ist in einem anderen Modul vorhanden: use.core
[ERROR] /C:/Users/akifn/Desktop/MyProjects/java/useTesting/use-gui/src/it/java/org/tzi/use/main/ShellIT.java:[1,1] Package ist in einem anderen Modul vorhanden: use.core
you can see in the file ERROR1
in engl it says the following:
package is avaiable in another module: use.core
in addition to that here the tree where you see where its located(treeGui), if I am correct I think its generated by mvn files?
it says it is in use core, but theres no file of any of both(DiagramUtilTest.java, ShellIT.java) inside usecore?
ok so compiling the integration test fails
try moving that to another package as well maybe
Note that it's use-gui/src/it
Yeah exactly
Ah so use-gui/src/it I have to move? 🤔
I wasnt sure about that Test File, bcs it seemed generated and I guess doesnt make any changes to be editing Generated stuff 😂
the ShellIT class in there
The ShellIT is alsso in org.tzi.main which cannot be located in multiple modules
What makes you think it's generated?
Idk these foulders where marked green so that confused me but i guess your right
green means test sources
i.e. these are used to test to check that the code works but not actually part of the code
I see
So these arent generated
I will change the foulders again than
The name*
yeah I'd say so
or actually there's also another way
it might also be possible to disable modules for the test
If the surefire plugin is used for that, you could specify
<useModulePath>false</useModulePath>
for thatah I did already change the names of both like added a subfoulder for both and works now but yeah in general all this Modules causing so many problems
so now there was a bat file which is just a script to run the jar, how would I need to change this now?
like since we have module-info.java in all classes this is causing problems this way of running it
I think I can delete the module path and add modules?
I guess just having had deleted the module-infos would have had been a way of avoiding all these
now it cant find use.core again
yeah that's kinda necessary
either you use the JAR with dependencies but then you have the same problems with JavaFX
or you run it without the module-info.jaav
Can you run
mvn clean
followed by mvn verify
? Does that succeed?
This seems like you still have the <appendAssemblyId>false</appendAssemblyId>
in one of the POMs
If the error only occurs in IntelliJ and not when running Maven, you can try mvn install
its only in this one:
but thats commented
which would fix the "IntelliJ handles multi-module projects badly" problem
and this is in a library
both did run
try that then
and then reload the Maven project in IntelliJ
using the reload button here
ah that one ok, was about to ask
your literally reading mind haha
alright I did
the mvn install and the reload
Does building from IJ work now?
java: No enum constant javax.lang.model.element.Modifier.SEALED
build fales
fails*
that means it isn't configured for JDK 21
or language level 21
actually it could be an annotation processor
Can you show the error message/full stack trace?
it showed me only that
Executing pre-compile tasks...
Loading Ant configuration...
Running Ant tasks...
Running 'before' tasks
Checking sources
Copying resources... [use-gui]
Copying resources... [use-core]
Parsing java… [use-core]
Writing classes… [use-core]
java: No enum constant javax.lang.model.element.Modifier.SEALED
Checking dependencies… [use-core]
Dependency analysis found 87 affected files
Errors occurred while compiling module 'use-core'
javac 21 was used to compile java sources
Finished, saving caches…
Compilation failed: errors: 1; warnings: 2
Executing post-compile tasks...
Loading Ant configuration...
Running Ant tasks...
Synchronizing output directories...
31.10.2024 11:35 - Build completed with 1 error and 2 warnings in 8 sec, 528 ms
Why are you using ant..?
Do you have a build.xml anywhere (not a pom.xml)?
seems like in ChangeLog and News
but its commented
...
ok I don't see a build.xml in the GH repo
so it might come from IntelliJ
Stack Overflow
What to do with "java: No enum constant javax.lang.model.element.Mo...
For a University project we need to implement a server 'registrar' that communicates with a client 'barowner' through a SSL RMI connection. When building the client, I get the error java: No enum
make sure you are using the correct SDK version everywhere
i.e. 21 and not 14
what about language level?
the Java version of the language features you want to use
it should be 21
it should be 21 everywhere
I checked
What are you doing so you are getting that output?
What is shown when right-clicking use-core?
Can you run
mvn help:effective-pom
?
See the "m" button in that image? You can use that to run arbitrary Maven commands from IntelliJ I thinkthis is when I did run in intellij on the Local Machine
seems like that click on "Open Module settings"
it's pretty much down at the bottom of the list
looks right
the output seems correct
that starts the Project Structure
it sais language level 17
there it jut goes back to language level 17 somehow
Can you check all modules? Is there any module using a language level lower than 17?
bcs there is no 21:
and when doing project default it goes back to 17
Do you have an old IntelliJ version that doesn't support Java 21?
i need to check that
actually it would be possible it selected the wrong JDK
Is there a Help > About menu or similar in IntelliJ?
that tells you the IntelliJ version
yeah seems old
should I update?
Java 21 was released in 2021 so your version should work
hmm I see
you could update to a newer version if you want to but you don't have to
Is there a way to change SDKs or project JDKs?
or module JDKs
this for example for sdks
Also check Settings > Build, Execution Deployment > Java Compiler
modules dependencies
Is it 21 for all modules here?
here I can type 21
it seems like a similar issue has been resolved in 2024.2 so you could try updating IntelliJ: https://youtrack.jetbrains.com/issue/IDEA-353958/Java11Java17-build-is-failing-with-message-java-No-enum-constant-javax.lang.model.element.Modifier.SEALED
maybe that works
ok il update than
Make sure to actually update to the newest IntelliJ version
ah i see its already at 2024.2
You mean you updated to it?
nono updating to it right now
ah ok
oh no
I guess updating from 2022 to 2024 version is too heavy
I might need to download it
seems like it tried to download a nonexisting version
If the project doesn't need Java 17+ features, you could also try downgrading to 16 (for the language level, you don't need a JDK for it)
But that wouldn't work if the project needs something from 17+
I did download the new version and omg does all look different
I think you can still enable the old UI if you want to
Does it build properly now?
so it does build and start the application, buttt..... many of the features seem to somehow not work anymore
like these work
and what doesn't work?
but when I try to for example press on that
idk where these problems coming from since before they worked
You can add
exports org.tzi.use.gui.views;
to the use.gui module
If you use modules, Java ensures that classes from one module cannot access classes from another module unless permitted
Or you can use the open
keyword to say "Anyone can access what's inside of this module"ah I get it
so I need to export them?
you can also use
exports org.tzi.use.gui.views to com.google.common;
to only export it to the com.google.common
modulehow do I do the open? I havent used open yet
yes
that means "any other module can access stuff in my module, including deep reflective access
so than I dont need to export anything anymore?
only require?
so I did the opens, why do i still get this than:
yes
Seems like
org.w3c.dom.ls.DocumentLS
doesn't existStack Overflow
NoClassDefFoundError: org/w3c/dom/ls/DocumentLS - issue occurring o...
Background
I have a project where I parse some XML documents and I happened to need the xerces dependency:
<dependency>
<groupId>xerces</groupId>
<artifactId>xerc...
so waht would this mean for me?
bcs I have only xerces xercesImpl
Maybe remove the xml-apis exclusion?
idk whether that causes the issue but it sounds likely
hmm its still there
<dependency>
<groupId>xerces</groupId>
<artifactId>xerces</artifactId>
<version>2.4.0</version>
</dependency>
this works
idk why but yeah
i kinda recreated what they used on so
<dependency>
<groupId>xerces</groupId>
<artifactId>xerces</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.11.0</version>
</dependency>
but the
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.11.0</version>
</dependency>
isnt needed in this case
Did you reload the Maven project after making the change?
soooo
yeah I forgot that it seems xD
but this one works:
<dependency>
<groupId>xerces</groupId>
<artifactId>xerces</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.11.0</version>
</dependency>
so the one on SO was right
so now that the swing version is working in intelliJ, it still does not work, when being called from the JAR
mvn verify did run succesfull thought:
that's because the version you used for combiling doesn't match the version you are running it with
When compiling Java applications to
.class
files, javac
adds an integer representing the version it has been compiled for to the class file.
Each Java version has a class file (major) version associated with it. A list with Java versions and the matching class file major version numbers can be found in this Stack Overflow question.
In order to use a class, the JVM must be of a newer or equal version to the one specified in the class file.You compiled it with JDK 17 but run it with JDK 21
you could change the PATH to use Java 21
you mean the envireomantal variable path right?
yes
I think you installed JDK 21 somewhere in your user home in a .jdks directory or something like that
ah lol I have had changed it but it went back to 17
maybe bcs of new installation of intellij it disappeared
How did you change it?
that's the JAVA_HOME which is used by Maven
in the path it seems not to be there anymore:
the PATH is used when running
java -jar
I see
I didnt know that
Maybe you just didn't set the PATH
its in the ath kind of
maybe the path is not correct anymore
?
idk i guess intellij didnt get it
just restartet intelij now it shows the right version
I think using things like
%JAVA_HOME%
doesn't work in there
you might need the full path there
but idk
you need to restart IntelliJ for it to applyso yeah it seems to work again
but now my part isnt working bcs of module-info again i think
since this is the original application the swing/awt one
and now my javafx version which is in the use-guiFX
oh WOW
this is actually my first error I can show you know
which did lead me to try using module-info.java
ok yeah I expected that at some point
So if you use modules, you cannot use the jar-with-dependencies
If you run
mvn dependency:copy-dependencies
, it should copy all dependencies somewhere in the target directorythis has been my first problem which I couldnt solve for days
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
Alternatively I think you can solve that by adding
--add-exports javafx.graphics/com.sun.javafx.sg.prism=ALL-UNNAMED
to the JVM arguments
Can you check that?it did do it succesfully
Did it put all dependencies of use-guiFX inside use-guiFX/target?
yes
Can you show the bat file?
@echo off
if "%OS%"=="Windows_NT" @setlocal
rem CONFIGURATION
rem Add -Xss20m to VMARGS when using the generator
set VMARGS=
REM PATH1: C:\Users\akifn\Desktop\MyProjects\java\useTesting\use-gui\target\use-guiFX-7.1.1.jar
REM PATH2: C:\Users\akifn\Desktop\MyProjects\java\useTesting\use-gui\target\use-guiFX-jar-with-dependencies.jar
set USE_JAR="C:\Users\akifn\Desktop\MyProjects\java\useTesting\use-guiFX\target\use-guiFX-jar-with-dependencies.jar"
IF NOT EXIST %USE_JAR% (
echo Cannot find USE executable. Please provide correct path to use.jar.
goto end
)
:runApp
java %VMARGS% --module-path "C:\Program Files\Java\openjfx-19_windows-x64_bin-sdk\javafx-sdk-19\lib" --add-modules javafx.controls,javafx.fxml -jar %USE_JAR% -nr %*
REM java %VMARGS% --module-path "C:\Program Files\Java\openjfx-19_windows-x64_bin-sdk\javafx-sdk-19\lib" --add-modules javafx.controls,javafx.fxml -jar %USE_JAR% -nr %*
if "%OS%"=="Windows_NT" @endlocal
:mainEnd
rem echo exit code: %ERRORLEVEL%
:end
brb have to do something parents calling, just so you know
Can you try running
java --module-path C:\Users\akifn\Desktop\MyProjects\java\useTesting\use-guiFX\target\use-guiFX.jar;C:\Users\akifn\Desktop\MyProjects\java\useTesting\use-guiFX\target\dependency\*.jar
wait
What's your main class?in use-guiFX its C:\Users\akifn\Desktop\MyProjects\java\useTesting\use-guiFX\src\main\java\org\tzi\use\mainFX\MainFX.java
then try running
java --module-path C:\Users\akifn\Desktop\MyProjects\java\useTesting\use-guiFX\target\use-guiFX.jar;C:\Users\akifn\Desktop\MyProjects\java\useTesting\use-guiFX\target\dependency\*.jar org.tzi.use.mainFX.MainFX
does the same
or do you mean me adding it to the VM options?
Can you try using cmd instead of powershell?
or maybe
java --module-path "C:\Users\akifn\Desktop\MyProjects\java\useTesting\use-guiFX\target\use-guiFX.jar;C:\Users\akifn\Desktop\MyProjects\java\useTesting\use-guiFX\target\dependency\*.jar" org.tzi.use.mainFX.MainFX
with the double quotessorry didnt realize it using powershell, I need to maybe go back to the old intellij design
I think it should work with either one in some way but idk how to deal with Windows terminal things
I think in PowerShell you can do something like
java --module-path "C:\Users\akifn\Desktop\MyProjects\java\useTesting\use-guiFX\target\use-guiFX.jar`;C:\Users\akifn\Desktop\MyProjects\java\useTesting\use-guiFX\target\dependency\*.jar" org.tzi.use.mainFX.MainFX
with a backtick before the ;
Running the command dir C:\Users\akifn\Desktop\MyProjects\java\useTesting\use-guiFX\target\dependency\
lists your dependencies (JAR files), right?
You can also try
on cmd or
in PowerShellYes
it does
try that
C:\Users\akifn\Desktop\MyProjects\java\useTesting>java --module-path C:\Users\akifn\Desktop\MyProjects\java\useTesting\use-guiFX\target\use-guiFX.jar;C:\Users\akifn\Desktop\MyProjects\java\useTesting\use-guiFX\target\dependency\ org.tzi.use.mainFX.MainFX
Error occurred during initialization of boot layer
java.lang.module.ResolutionException: Modules jdk.xml.dom and xml.apis export package org.w3c.dom.html to module javafx.graphicsEmpty
ok it seems like this exclusion might have been necessary
and make sure to run
mvn clean package dependency:copy-dependencies
after changing the pom.xml
to ensure everything is copied againi dont get it, bcs that one was in use-gui and not use-guiFX
ah ok
il do that
JavaFX seems to try to access that package but there are two modules with that package
now says this:
Error occurred during initialization of boot layer
java.lang.module.ResolutionException: Modules xercesImpl and jdk.xml.dom export package org.w3c.dom.html to module antlr.runtime
apis is gone
no wait
its still saying xercesImpl
the message is a bit different but yeah still contains same packageYou might also need the exclusion in xercesImpl
i did it like that
you mean include the exclusion also on the top one?
I think that might be https://issues.apache.org/jira/browse/XERCESJ-1706
bcs I mean it is already in xercesimpl?
what kind of solution is that xD
idk what that does
to delete org.w3c.dom.html.HTMLDOMImplementation
because it shouldn't be in xerces from the start on I think
but you can also try the alternative solution of ignoring modules
Did you manage to run the guiFX thing from IntelliJ?
no that didnt work
maybe we should look into that first?
oh then you should try making sure that works first yes
I thought that works
my fault I forgot to say that here
alternatively it might also be possible to make a JAR with dependencies and try to figure out all the other stuff as a backup solution
should this be in the VM Options or not:
--module-path
"C:\Users\akifn.jdks\corretto-21.0.5\lib"
--add-exports
javafx.graphics/com.sun.javafx.sg.prism=ALL-UNNAMED
when running it like this:
I think not
Try using the reload button in the Maven tab and try again
I think from what I did understand when using module-info theres no vm options needed
and remove these VM arguments
Why do you have a package named
bin
?
What's in there?in both it in the ressources
in with the .bat files are
I guess I need to rename the foulder again in FX
instead of renaming the files in it?
thi is like from earlier, where I thought that changing file names would fix it
Why are these in the resource directories?
Did you put them there?
It's enough to move them outside of the resources directory in the guiFX module I think
that was the structure how it was in use-gui
yeah but you shouldn't have the same packages in multiple modules
I just wanted to have my solutions all seperated from the SwingAWT solution
you can still have that
but that doesn't mean you have to copy stuff 1:1
but yeah the way I work has changed since than, I am using swing/AWT parts inside my javafx so thats something causing these problems, bcs modules cant have same strucutre
Is there a reason the guiFX thing depends on the swing GUI?
exactly haha but as i say first it was thought of both having nothing to do with each other
yeah as I said, inside the javafx parts I still use the swing parts with SwingNode
ah ok
thats only the first step so that all functionality is given
yeah just make sure that you don't use the same directories in src/main/java and src/main/resources
and than step by step the parts should be migrated
so can I just change the name of bin to binFX or what would be best to do?
soo I changed the names
now i get following Errors:
this also worked earlier
for example or completely move it out of the resources directory
Does that file exist?
Can you show the code loading it? I think it might be part of the Main.fxml
yeah exactly:
I am using fxml
If you remove the
stylesheets="@/styles/style.css"
from the FXML and uncomment the scene.getStylesheets().add(getClass().getResource("/styles/style.css").toExternalForm());
, are you getting the same error?
Did you use open module
in the guiFX module-info.java?that part is commented not used
ah no
you can try that
yeah I meant making it a non-comment
i.e. removing the
//
oh ok
either that or using
open module
could also work
open module
is kinda the opposite of the goal of modules (modules are supposed to make sure that stuff is only accessible by what is supposed to access it and open
means "everything can access my stuff"till the same
That was with
open module
but without the change to the FXML file, right?both
oh it's a different exception
What's line 790 in MainWindowFX?
Is it
primaryStage.getIcons().add(new Image("images/use1.gif"));
?Image image = new Image(Objects.requireNonNull(MainWindowFX.class.getResourceAsStream(Options.getIconPath(name))));
oh thats prob bcs i changed the foulder name
ok yeah it doesn't find that icon
the
Objects.requireNonNull()
fails because it is nulli did put this in there now:
Image image = new Image(Objects.requireNonNull(MainWindowFX.class.getResourceAsStream("/imagesFX/" + name)));
before it was using this methode
This message has been formatted automatically. You can disable this using
/preferences
.What's line
176
?
same issue ther?yes not its running
You mean now?
like from inside IntelliJ
ok
but yeah things still not working in it which did work earlier I checked
?
but I have to first change the paths
Btw if you want to run it from the command-line there is one easy way I didn't tell you before which should work but it requires Maven for running the application
like from images to imagesFX and such
yeah I guess
you can also use a constant for that btw
Trueee
so true haha
either a constant or one method that is used everywhere
or a method used everywhere that uses a constant
whatever you like
thank you! I will note that down and think about how to do that later
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
so now it working in IntelliJ
il check mvn verify now
verify went well as expected
but yeah I cant run the jar with dependencies:
PS C:\Users\akifn\Desktop\MyProjects\java\useTesting> use-guiFX\src\main\resources\bin\useFX.bat
use-guiFX\src\main\resources\bin\useFX.bat : Das Modul "use-guiFX" konnte nicht geladen werden. Wenn Sie weitere Informationen wünschen, führen Sie "Import-Module use-guiFX" aus. In Zeile:1 Zeichen:1 + use-guiFX\src\main\resources\bin\useFX.bat +~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (use-guiFX\src\m...s\bin\useFX.bat:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CouldNotAutoLoadModule
dont I have to take out the module-path and such in my :runApp? inside the start_useFX.bat?
use-guiFX\src\main\resources\bin\useFX.bat : Das Modul "use-guiFX" konnte nicht geladen werden. Wenn Sie weitere Informationen wünschen, führen Sie "Import-Module use-guiFX" aus. In Zeile:1 Zeichen:1 + use-guiFX\src\main\resources\bin\useFX.bat +
You can also try running
mvn -f use-guiFX\pom.xml exec:java -Dexec.mainClass=org.tzi.use.mainFX.MainFX
if yu want to run it from the console
That's the easy way to run it with Maven
Which means "use the pom.xml from the use-guiFX module and run the org.tzi.use.mainFX.MainFX
class"
It might be necessary to do mvn install
firstah ok
If you don't want to run it with Maven each time, you can try the following in your script:
This is the command from earlier
that didnt work
its showing same message errors
The one about a package being accessible from multiple modules, right?
related to xerces
What is xerces used for?
PS C:\Users\akifn\Desktop\MyProjects\java\useTesting> use-guiFX\src\main\resources\bin\useFX.bat
use-guiFX\src\main\resources\bin\useFX.bat : Das Modul "use-guiFX" konnte nicht geladen werden. Wenn Sie weitere Informationen wünschen, führen Sie "Import-Module use-guiFX" aus. In Zeile:1 Zeichen:1 + use-guiFX\src\main\resources\bin\useFX.bat +~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (use-guiFX\src\m...s\bin\useFX.bat:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CouldNotAutoLoadModule
use-guiFX\src\main\resources\bin\useFX.bat : Das Modul "use-guiFX" konnte nicht geladen werden. Wenn Sie weitere Informationen wünschen, führen Sie "Import-Module use-guiFX" aus. In Zeile:1 Zeichen:1 + use-guiFX\src\main\resources\bin\useFX.bat +
oh that's something else
I think Powershell didn't like you running a bat file
ahh
I think you can run
cmd /c use-guiFX\src\main\resources\bin\useFX.bat
in PowerShell and it should run the bat fileI forget Its powershell default
thats so stupid
I think you can change that in IntelliJ
the old version didnt have that yeah
and I am thinking like whats these messages xD
and I think it's also possible to create a run configuration that runs a bat file
I'm glad I'm using Linux and having a terminal I understand xd
it cannot find the path it says
you changed the folder
it's no longer bin
I think
That may also be the reason for the error you just got with powerShell
true
ah thats stupid changes foulder names is pain haha
ah I am so stupid
now i got it
use-guiFX\src\main\resources\binFX\useFX.bat
this one needs binFX
Oh and if you make a change to the program, you might need to run
mvn clean package dependency:copy-dependencies
before running the script to ensure everything is therexD
You can also make it such that
mvn package
or mvn verify
or whatever is sufficient by modifying the pom.xmli was mostly just using mvn verify
so i would in addition also need the mvn clean....
You can configure it that
mvn verify
also copies the dependenciesah I see
mvn clean
just deletes the target
folders
so if you remove a dependency, that would still be in target/dependency
and the clean
gets rid of that
anyways that command should also work if Maven etc is installed
so you could also use that in your bat - if you are ok with relying on Maven to run ithow would I do it if I dont want to rely on maven?
or should i be relying on maven and editing the pom? 🤔
First use Maven to build all the JARs (e.g.
dependency:copy-dependencies
and package
which could be done in one step)
Editing the POM would only be necessary once
and then run Java with these JARsso this is my current start_useFX.bat
There are also other ways that include making an installer or similar which is a bit harder to set up but makes running it easier
I would build these in there?
You only need these commands to ensure all JARs are where they should be
I got overwhelmed a bit I am sorry
And it is possible to configure Maven to automatically do
dependency:copy-dependencies
on package
Yeah I understand that
What exactly are your requirements for the script?like currently its working with doing
mvn verify
on changes and then running it with use-guiFX\src\main\resources\binFX\useFX.bat
Is that working?
I just want it to run haha
You managed to run it with
mvn -f use-guiFX\pom.xml exec:java -Dexec.mainClass=org.tzi.use.mainFX.MainFX
so you could also just put that in the start_useFX.bati am a bit confused bcs I think this part in the .bat is wrong and I need to edit
:runApp
java %VMARGS% --module-path "C:\Program Files\Java\openjfx-19_windows-x64_bin-sdk\javafx-sdk-19\lib" --add-modules javafx.controls,javafx.fxml -jar %USE_JAR% -nr %*
.
so this one would run it with mvn then right?
but is it than also like doing the verify?
or actually I think
mvn -pl use-guiFX exec:java -Dexec.mainClass=org.tzi.use.mainFX.MainFX
would be better
yes
I think that isn't even necessary with mvn -pl use-guiFX exec:java -Dexec.mainClass=org.tzi.use.mainFX.MainFX
The idea of the script is that you can use Maven to build JAR files and then run the JAR files from the scriptok wait I am so confused haha
bcs that one is working now
so I can put this now inside the bat?
yes
But then you will need Maven if you want to use the bat
That's your choice
that means?
I mean I have already maven dont i?
If someone wants to run the bat, they need to install Maven
:runApp
java %VMARGS% --module-path "C:\Program Files\Java\openjfx-19_windows-x64_bin-sdk\javafx-sdk-19\lib" --add-modules javafx.controls,javafx.fxml -jar %USE_JAR% -nr %*
mvn -pl use-guiFX exec:java -Dexec.mainClass=org.tzi.use.mainFX.MainFX
so thee two runApps
You don't need the
java %VMARGS% --module-path "C:\Program Files\Java\openjfx-19_windows-x64_bin-sdk\javafx-sdk-19\lib" --add-modules javafx.controls,javafx.fxml -jar %USE_JAR% -nr %*
for Mavenfor one they would need mvn for the other one not?
Maven does that for you
also
java %VMARGS% --module-path "C:\Program Files\Java\openjfx-19_windows-x64_bin-sdk\javafx-sdk-19\lib" --add-modules javafx.controls,javafx.fxml -jar %USE_JAR% -nr %*
would be wrongI see but what about the dependencys now?
does it do that a well?
The dependencies are needed if you want to run it without Maven
which I think doesn't even work yet
exactly
If you want to only run it with Maven (or from IntelliJ), you don't need the
dependency:copy-dependencies
thats the problem
like someone should be able to call via cmd or such this one use-guiFX\src\main\resources\binFX\useFX.bat and the application should start
thats the idea
and I think when using mvn here this doesnt work or does it?
Well someone would need to compile it and give them the files first
It is possible to make it work (and pretty easily) but it would require the person using the batch script to install Maven first
The other way is the one with JARs where idk how well that would work / how we can get it to work
hmm I see
idk what exactly you want/need
my project is actually "just" the migration from swing to javafx* Kind of
I think the intent of the bat script is to run it without Maven
I have had recreated the swing awt gui as javafx, and after building in 2 functionalities as javafx, I decided to do just use for now the swing functionalities inside the javafx components.
So that I would first have all the functionalities, before I continue the migrating
yeah like its a application that exists and I am trying to modernize it
next I wanted to check out browser engineering, to see if I could build some parts that way
so that it could be at the next step be created sometime later as a web version
If you think it's fine for now, you could also commit and push it and then work on it more (e.g. fix the bat) later
that sounds like a good idea
btw if I delete the dependency foulder in the target it should still work right?
bcs its not being used as you did say
What exactly should still work?
running the start_use.bat
running from cmd
You can also just replace the script with
or similar
Did that one ever work?
yes
Are you talking about the Swing or JavaFX one?
swing and javafx one
The Swing one should still work
But I thought the JavaFX one doesn't even work with the dependency folder?
yeah it works
so javafx and swing version both did work, but until I started using WebView
ah right
and than when I started using module-info.java
yeah didnt work anymore
haha
but yeah now with the mvn call you created it does work again
We could still try to get it withing with Webview and the jar with dependencies
you mean we could try it without the module-infos?
or you mean now without mvn?
Sorry if I am sometimes understanding late
First make the JAR with mvn and then run the JAR without Maven
We could try it but idk whether it works
You could also just try changing
--add-modules javafx.controls,javafx.fxml
to --add-modules javafx.controls,javafx.fxml,javafx.web
But the --add-modules
shouldn't be necessary at all once it works wellah here yes
so when using this now
:runApp
java %VMARGS% --module-path "C:\Program Files\Java\openjfx-19_windows-x64_bin-sdk\javafx-sdk-19\lib" --add-modules javafx.controls,javafx.fxml,javafx.web -jar %USE_JAR% -nr %*
I get this one
the one i was talking about from since the beginning and why I started using module-info
it says stuff like unnamed module
I think you can fix that error by
--add-exports javafx.graphics/com.sun.javafx.scene=ALL-UNNAMED
but idk how many errors you'd get
yes because as soon as you have a JAR with dependencies, modules don't work anymorethats the thing I have had tryed all these but couldnt fix it
Where did you add it?
use> Exception in thread "JavaFX Application Thread" java.lang.IllegalAccessError: class com.sun.javafx.embed.swing.SwingNodeHelper (in unnamed module @0xddefd7b) cannot access class com.sun.javafx.util.Utils (in module javafx.graphics) because module javafx.graphics does not export com.sun.javafx.util to unnamed module @0xddefd7b
with that one i get this
now inside the bat
:runApp
java %VMARGS% --module-path "C:\Program Files\Java\openjfx-19_windows-x64_bin-sdk\javafx-sdk-19\lib" --add-modules javafx.controls,javafx.fxml,javafx.web --add-exports javafx.graphics/com.sun.javafx.scene=ALL-UNNAMED -jar %USE_JAR% -nr %*
but earlier this and last week always in the VM Options
--add-exports javafx.graphics/com.sun.javafx.embed.swing=ALL-UNNAMED
yeah that's fine as long as it's before the -jar
The thing is idk how many --add-exports
that needsuse> Exception in thread "JavaFX Application Thread" java.lang.IllegalAccessError: superclass access check failed: class com.sun.javafx.embed.swing.SwingNodeHelper (in unnamed module @0x161e0b82) cannot access class com.sun.javafx.scene.NodeHelper (in module javafx.graphics) because module javafx.graphics does not export com.sun.javafx.scene to unnamed module @0x161e0b82
I think there may be another approach but that would either make the program only work on one OS or it would make the JAR significantly bigger
oh did you mean keeping the other add exports and adding this one
but then it wouldn't require any
--module-path
or --add-modules
yeshmm I see
so mvn is the better solution after all?
It's the easier solution for you
But it isn't easier for users
And I think the project wouldn't like that solution
use> Exception in thread "JavaFX Application Thread" java.lang.IllegalAccessError: class com.sun.javafx.embed.swing.SwingNodeHelper (in unnamed module @0x6a6681f1) cannot access class com.sun.javafx.util.Utils (in module javafx.graphics) because module javafx.graphics does not export com.sun.javafx.util to unnamed module @0x6a6681f1
this comes when having both
java %VMARGS% --module-path "C:\Program Files\Java\openjfx-19_windows-x64_bin-sdk\javafx-sdk-19\lib" --add-modules javafx.controls,javafx.fxml,javafx.web --add-exports javafx.graphics/com.sun.javafx.scene=ALL-UNNAMED,javafx.graphics/com.sun.javafx.embed.swing=ALL-UNNAMED -jar %USE_JAR% -nr %*
idk if I can do , between them
I guess so would make sense
Another
--add-exports javafx.graphics/com.sun.javafx.util=ALL-UNNAMED
You can find it from the error message
the issue is I have no idea how many you need
It could be a lot
ah so you get it from the message
but this seems odd
WARNING: Unknown module: javafx.graphics/com.sun.javafx.embed.swing=ALL-UNNAMED specified to --add-exports
WARNING: Unknown module: javafx.graphics/com.sun.javafx.util=ALL-UNNAMED specified to --add-exports
It might be possible to do it in a way that doesn't require any
--add-exports
and no JavaFX SDK by telling Maven to include the stuff for Windows, MacOS and Linux in the JAR
What exactly did you put in the JAR?good question
this one right:
use-gui-jar-with-dependencies
yes
Essentially you could add
<classifier>win</classifier>
to all JaavFX dependencies and then it would work for Windows
and then you could just run it with java -jar
and don't need to do anything with modules - maybewin for the winners haha
il try that out
The important thing when doing that is the following: Don't run it with
--module-path
, --add-modules
or --add-exports
so this one
:runApp
java %VMARGS% --module-path "C:\Program Files\Java\openjfx-19_windows-x64_bin-sdk\javafx-sdk-19\lib" --add-modules javafx.controls,javafx.fxml,javafx.web --add-exports javafx.graphics/com.sun.javafx.scene=ALL-UNNAMED,javafx.graphics/com.sun.javafx.embed.swing=ALL-UNNAMED,javafx.graphics/com.sun.javafx.util=ALL-UNNAMED -jar %USE_JAR% -nr %*
would look like this?
:runApp
java %VMARGS% -jar %USE_JAR% -nr %*
you mean like this:
yes
and run
mvn package
or mvn verify
before running the JARbtw can I deleat this now:
ok
since I think you did say we dont need it anymore
mvn clean
automatically deletes it btwdid you fix it?
ah okey
kind of, we are trying something out
did you check if your javafx versions match the version on your project?
not really the problem
I think dan1t would have realized that problem after 5 messages haha
I wish it would be just that haha
@dan1st | Daniel
C:\Users\akifn\Desktop\MyProjects\java\useTesting>use-guiFX\src\main\resources\binFX\useFX.bat
Fehler: Zum Ausführen dieser Anwendung benötigte JavaFX-Runtime-Komponenten fehlen
well probably, but I just ran into this issue literally 2 days ago and it resulted in the exact same problem you are experiencing so it was worth a shot
it says it needs the needed javafx-runtime-components which are mising
Did you run
mvn package
before running the bat file?:runApp
java %VMARGS% -jar %USE_JAR% -nr %*
when I called it like this
I did mvn verify
yes that's fine
ah I see thank you still
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
glad to hear yours got fixed
so i guess the classifier>win< wont work here?
Can you show the pom.xml?
I've ran into this before too. This might sound weird but did you try making a new main class that just calls the main in your application that calls launch? It did the trick for me.
my problem is kind of a bit bigger to be fixed jut this way sadly
it a problem with swing/javafx and the project being Multi Module
just give it a try, it will take you around 30 seconds and can be easily reversed. My project was multi module too with javafx
it was a real odd solution and to this day I have no idea why it worked
thats the best problems when you get them fixed and really dont know whats happening haha
the "proper" solution would be the thing with copying dependencies - or jlink
but the issue with that is split packages
yup
I see yeah the split packages issue we had
which could in theory also be solved with extracting the offending dependency
which would be doable but kinda annoying
alright il stick with mvn for now than
I can tell you something that can be done:
You can change the guiFX pom.xml to do the following:
- When
mvn package
is executed, it runs dependency:copy
but excludes xercesImpl
- It extracts xercesImpl but removes the class causing the split package issue
And then in your bat, you can run the project with --module-path
on:
- The JAR generated by mvn package
(not the jar-with-dependencies)
- The copied dependencies
- The extracted dependency
So essentially do some changes to the guiFX pom.xml and change the bat a bitalright I will note this down for now and check it out later definetly
for now I reached something big, which was getting this problem "fixed" since I wasnt able to run from cmd since 2 weeks
@dan1st | Daniel if I should have questions or problems can I msg you or should I just post it in #java-help again?
You can create a post again
or if you don't close this post, you can still use it
ah posts are there forever?
If you want to, I can show you what I think this would look like
like "inactive"
yeah sure would like to see
Posts can go dormant after some time of inactivity but the post would stay there
but it may be harder to find
alright Il reach out here then!
your such a life saver man thank you very much :boohoo: 🤍
JavaBot is so sick of me haha
btw do you know how I can get rid of these long messages:
Then you build it with
mvn package
(or mvn verify
)ah thats what these xerces do
and then you should theoretically be able to run it with a bat like
xercesImpl was the dependency causing the issue with org.w3c.dom.html.
This step would change it so that this part would not be included.
btw that would need to be in the guiFX POM
Does that approach work like that? idk I didn't test it
yes yes got that
maybe I also messed up some configs, I jsut typed that out
idk I would need to test it out later
but it looks good
Also practically you'd probably want to put all these things together in some directory (with the bat file) which you can then give to others who can just run it
you mean the whole project?
I guess you mean my javafx part
only the things generated there meaning:
-
use-guiFX/target/dependency
- use-guiFX/target/use-guiFX-YOUR_VERSION_HERE.jar
- use-guiFX/target/xercesImpl
- use-guiFX/src/main/resources/bin
these would (ideally) be requiredI am back faster then I thought haha
sooo I realized a big flaw of our solution, so the other solution allows parameters to be added to the .bat call like this for example:
use-gui\src\main\resources\bin\use.bat C:\Users\akifn\Desktop\MyProjects\java\useTesting\use-core\src\main\resources\examples\Documentation\Fruits\Fruits.use
our call with mvn, would that somehow support something like that?
so the %* it could contain a few parameters
yes, that's possible
I think you can do
mvn exec:java ... -Dexec.args="%*"
or similar
if these are separated by spacesmvn -pl use-guiFX exec:java -Dexec.mainClass=org.tzi.use.mainFX.MainFX
so here how would i do that here?
mvn -pl use-guiFX exec:java -Dexec.mainClass=org.tzi.use.mainFX.MainFX -Dexec.args="%*"
idk whether %*
is the right thingah so another dexec
I don't know batch that well
yes
I see thank you il test
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
-Da=b
means "tell maven that a is set to b"yeah %* should be correct
so you are setting
exec.args
to whatever is %*
that I will try to find out
So when i add it like this:
:runApp
mvn -pl use-guiFX exec:java -Dexec.mainClass=org.tzi.use.mainFX.MainFX -Dexec.jvmArgs="%VMARGS%" -Dexec.args="%*"
I get following:
java.lang.NullPointerException: in
(MainWindowFX.java:159)
which is this:
inside MainWindowFX
This message has been formatted automatically. You can disable this using
/preferences
.it means that
fModelBrowser
is null
btw for development, you can just run the main from IntelliJidk its just a feature that should be there, but I will see if its ok this way
btw I pinned that so you can easily find the message if you want to come back to that in the future
Ah thats great Thank You bro, I will definetly come here a few times, bcs need to document properly what we did here and what I tryed :thumbs:
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
Idk seems to be not working kind of
Idk why but it says that packages arent visible
What's your full bat file?
and the pom.xml of the guiFX module
set USE_JAR="C:\Users\akifn\Desktop\MyProjects\java\useTesting\use-guiFX\target\use-guiFX-jar-with-dependencies.jar"
That shouldn't be the jar-with-dependenciesbut the normal JAR
ah yeah you did say so true
why again was it supposed to be not that one?
the jar-with-dependencies means you have one JAR with all classes together in one place
btw here I too out the :
part
this doesn't work with modules that require one JAR or directory per module
but wasnt that the goal to be achieved "mocked" with package?
you mean with the thing in the pom.xml? That makes sure the dependencies are in the correct directories
like it copies all dependency JARs somewhere and also fixes the xercesImpl stuff
I get till the same one I just the jar without dependencies
yes exactly
You have
use-guiFX/src/main/java/org/tzi/use/mainFX/MainFX.java
in your bat. I think that should be org.tzi.use.mainFX.MainFX
this path somehow doesnt work, thats why I used that one:
or maybe
-m YOUR_MODULE_NAME_HERE/org.tzi.use.mainFX.MainFX
it says could not be found
What's the name of the guiFX module?
in the module-info.java
idk that somehow sometimes happens
il check:
This message has been formatted automatically. You can disable this using
/preferences
.java %VMARGS% --module-path "%USE_JAR%;%USE_DEPENDENCIES%;%USE_UNPACKED%" -m use.guiFX/org.tzi.use.mainFX.MainFX -nr %*
oh wow that one worked
what did that change?
o you defined the module which one it needs to use?
ahh I guess it was looking in a different module maybe
Saying "I want to run the class
org.tzi.use.mainFX.MainFX
from the module use.guiFX
makes totally sense
if you use
use-guiFX/src/main/java/org/tzi/use/mainFX/MainFX.java
, it tries to run use-guiFX/src/main/java/org/tzi/use/mainFX/MainFX.java
and figure out stuff by itselfprob my structure making problems
which didn't know about modules properly as it seems
That one is using the source code launcher which is (currently) not made for things with dependencies
Ty! but so how could someone run it now without having the need to have the whole project?
First of all, you need to make a few changes
like you know when someone has the jar with dependencies they can run it without needing the project like in the swing version
Like you would not use full paths
I might have these in a few spots I need to edit that :check:
One option would be to give them a zip file containing
- the
dependency
directory
- the guiFX JAR
- the xercesImpl
directory
- the bat
file
and ensure the relative paths are set up in a way that it works whenever extracting the zip file
you can also configure Maven to put everything in a single directory with the correct layout
But since it works, you might want to commit and push firstxercesImpl Directory? I dont have that
like as I did say I did took out that part
Ah I had a typo there sorry
I took out that xerces part bcs it was causing problems
so this is the only thing added in pom.xml as a new plugin:
it's generated by Maven in the target directory
that's the
unpack
part heretheres nothing at least I didnt see it
but if it works without it, ig that would be fine
btw can you maybe Help me out with a few warnings that kinda sound concerning when doing any mvn call?
like I did check stackoverflow but It felt like all they where saying i accept it theres nothing to fix it ☠️
sure
let me guess: encodings?
its these ones
Required filename-based automodules detected:
https://stackoverflow.com/questions/46501047/what-does-required-filename-based-automodules-detected-warning-mean
Oh yeah exactly I should do that first, before anything else
ahh that
The good news about that warning is that you can pretty much ignore it as long as you don't publish it to a Maven repository
and if you are able to change names in the module-info.java if that's necessary in the future
but that would be something these library maintainers have to fix
btw a better way would be to use jlink/jpackage which can create a full minimal Java installation that includes everything necessary
but that's more complicated to set up
and note: You can also configure Maven to automatically copy the bat file etc to the right location using the resource maven plugin if you want to
what exactly define a maven repository?
am I not publishing it to one?
If you have a library and you want others (not working on the same project) to easily use it with
<dependency>...</dependency>
, you need to publish it to a Maven repository (typically Maven Central)
since that isn't the case with you, that wouldn't be an issueah yeah jpackage was the next thing I thought about
I heared thats for javafx to create a runnable application for them kinda old but yeah
jut watched a video on youtube about it today, dont know thought how it would work out, but was looking forward to it, but first wanted to try out what you told me here
amazed that this worked
btw I think if you build it on Windows, it might only work on Windows
because the JavaFX Maven plugin might select the Windows version of JavaFX
ahh thats that maven central thing, have read about it before
not sure though
i guess i am not using it so far and not needed
Yes, Maven Central is the main Maven repository
you are using it for your dependencies but you aren't publishing anything to it
and I dont need to right? like other people could still run it wiht the bat?
hmm fair point that could be something to keep in mind
I might try it out later on an macbook
Currently your bat uses absolute paths
so you'd need to fix that
Note that MacOS cannot run batch files so you'd need to adapt the shell script as well
Note: With jlink/jpackage, you would create different artifacts/files/installers/whatever for different operating systems
yeah on it, I think I can use like %~dp0 or so
but you'd need to create these files on the operating systems you want to target (e.g. you need MacOS if you want to build it for MacOS). However, you can use things like GitHub Actions to do that for you.
idk what exactly
%~dp0
but there are likely alternatives with bash
e.g. $*
i actually dk if the original swing version had cross compatibility
Swing is part of the Java standard libraries
I would need to check that out first, until than Il put that on lower priority i think
So if you download Java, you are also downloading the Swing version for the same OS
ah ok so its only a javaFX problem?
bcs its not in the java standard library anymore?
Well it's also generally a thing if you use jlink/jpackage
yeah pretty much
hmm I see
You could also say "Users have to download Java and the JavaFX SDK" to avoid this problem but do you really want to do that?
I have to look more into it than
Idk, but I guess you wouldnt want to do that normally
Currently with the Swing version it would probably be users having to download Java
yeah thats currently a must anyways exactly
With jlink/jpackage, everything would come with the application
including Java
ah I see
i didnt know java also in it in the "package"
and including JavaFX and including dependencies
that's what jlink/jpackage does
i was thinking only the dependencies like a jar with dep
just like as a java solution kinda
jlink --> create a partial Java installation that only contains what you need (and also some extra things like your application and dependencies if you want to)
jpackage --> pretty much like jlink but it can create it as a single executable installer
hmm so what would you recommend I should go for
should I like do the Zip? or should I do one of these both
Il need to first fix my code haha
at least the call works now with java form the bat and not with mvn, thank you Daniel!
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
For now, you could make sure that Maven puts all files in one directory you can easily create a zip file from. So such a directory would contain
- the stuff from (I think) src/main/resources/bin
- You'd need to update the paths there
- the guiFX JAR
- the dependencies
- the xercesImpl folder if necessary
if you have a directory like that (let's say target/dist) where Maven puts all these things automatically, you could just create a zip file and give that to others. After extracting that zip file, they could just run the bat
In principle, I think it would also be possible to make that work for multiple OSes but that would increase the size of the zip file (and you can still do that independently from the other things)
Thank You @dan1st I will check these out and try that out!
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
Mannnn @dan1st I can call now from the cmd with Parameters its working OMG
nice
Thanks to your help bro, I am sooo happpy
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
has been a while I felt so good ngl
i will sleep well tonight
we are geniuses
good night
Thank You and wishing you the same
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.