I'm having a problem with resources that I add to my Java project with Maven and I'm not quite sure what the issue is.
I'm using IntelliJ. But have also tried using Eclipse with the same issue.
When I add a resource to my POM file and it downloads. I add it to my project but I am unable to fully use it.
For example, the WebDriverManager resource for Selenium. https://mvnrepository.com/artifact/io.github.bonigarcia/webdrivermanager/3.7.1 it has a method for setting it up that is WebDriverManager.chromedriver().setup();.
However, I can only type in WebDriverManager with the rest of the command not being recognised and highlighted in red.
The same is occurring with Selenium itself when I add it via the POM file. I am unable to use the library fully with most commands going unrecognised.
Is this possibly a permission issue?
I fixed the issue. This may sound obvious but I was previously trying to use methods outside of the main method.
Once I put the code in the main method. Things worked.
Doh.
Related
Trying to set up debugger for spring aplication. Based on the comment from this What creates target directory in spring boot application?
I might need artifacts.
I do not know hot to set up the artifacts for spring boot application, so trying to set up by cmd application article https://www.jetbrains.com/help/idea/debug-a-java-application-using-a-dockerfile.html
I did not set Main class, because I have no idea what is main class in my project. I tried searching function main() but did not find it. So I had set up:
Running Build > Build Artifacts and choosing my jar artifact, I get
/home/agmis/projects/openelis/src/main/java/org/openelisglobal/dataexchange/fhir/FhirUtil.java:4:46
java: package org.itech.fhir.dataexport.core.service does not exist
I think there is high chance that this part of code works, because I have been debuging related code, seen that function. So I am just probably getting this error when building artifacts. And the function is modified on April 5 this year, so this also adds the confidence that this part of code works.
I see interface is in red, and import is grey so because IDE also does not see it.
So how to fix that?
Also if you can give a link to a good tutorial on how to setup debugger with docker which would solve me this problem and maybe I would not even get this error, this could make the problem solved also.
Update
Based on Renato "Reload All Maven Projects" - did not help, same problem still.
I've come back to project after a long diversion, and upgraded tooling. This means Netbeans 12.5, Java 17, Gradle 7.3… at least allegedly. For some reason, despite setting the Gradle version to 7.3, it appears to build with 7.0.
Per the image below, setting the Gradle version to 7.3 doesn't seem to be picked up. (That is immediately after hitting Apply.) It still tries to build with 7.0. And – for some indeterminate reason – it can't.
Restarts don't help; I can't get the configuration to be picked up. (Searches for reference to similar issues provide 5-year-old answers that are no longer relevant.) I've even tried deleting the 7.0 distribution; to no avail, it comes right back.
Can anyone provide guidance on getting this to work properly?
Netbeans 12.6 fully supports Java 17 and Gradle 7.3. Gonfiguring the Gradle wrapper for 7.3 gets picked up correctly, eliminating all errors I was experiencing.
Don't bother with gradle in Netbeans. It's a horrible, buggy disaster and 12.6 just seems to want to up the ante.
Netbeans does NOT support gradle in a meaningful way for normal users.
You now get complex multi-projects whether you want them or not.
When creating a Java Application you don't get a choice at what the Main class is called. It will be App with app.java and you will like it.
If you try to rename app.java to something useful. It will not change "Class App" to "Class Useful" it will instead change it to "ClassUsefulp". It will not rename the test file and you will be left with several syntax errors that you can have fun cleaning up.
No, you cannot rename the subproject itself. That will continue to be the extremely descriptive and useful "app" subproject. The IDE will not provide you a way to rename that.
There is no meaningful, intuitive way to create/delete/modify subprojects.
If your gradle version is somehow out of sync there is still no useful way to reset/recreate the gradle wrapper other than creating a whole new project and moving your source code over to the new project.
Oh, so you gave in and accepted the multi-project structure. You noticed that if you go through the multi-project creator GUI then you can create multiple subprojects. Yeah, good luck with that. They won't have gradle build.scripts or wrappers. You won't be able to build your awesome creation.
Want to use command line arguments? Forget it. There is no "run" element in the project properties. You cannot create different run configurations.
Want dependencies? Or any other project configuration? It's all manual editing of gradle files. There's no GUI to assist non-gradle-wizards.
Yeah. you can probably work around a lot of this by dropping to a command line shell and editing the gradle scripts/files manually and running gradle commands manually. A) you're going to need to be a gradle wizard, and B) why are you using an IDE in the first place? you've got gradle, you've got vi available. Bathe in the nostalgia because you'll have to anyways.
Do you like the idea of gradle? Do you use Netbeans? Stick with Ant, or Maven if you need external dependencies; you'll thank me later.
IntelliJ newcomer here. I'm having some issues getting my project dependencies working:
So I have a project called ClearDialogue. It's an IDE for making branching dialogue for video games. It relies on my other project, Clear (ClearVG and ClearWindows) for creating its window and also rendering the UI. ClearDialogue also depends on LWJGL3 and a few other dependencies. The projects use Maven to manage its dependencies.
Clear is a project on my machine that I've set up in IntelliJ and successfully ran its demos. ClearDialogue however is where my trouble started; it relies on Clear to work, which is another project (not a JAR thats uploaded for it to fetch). So what I'm saying is: I need to be able to use another IntelliJ project as a library in ClearDialogue.
According to other similar questions, I can achieve this by referencing the other project in the pom file of the project that's referencing it. So I did that and it actually did appear in the "External Libraries" dropdown:
.
There are a few problems:
1) Despite Clear appearing in the External Libraries section, it's still not being recognized by the IDE as a library and when I try to build the project, errors like this are printed to the console:
.
2) It seems that Clear is the only library being downloaded despite LWJGL3 and other libraries being designated as dependencies in the pom file. They aren't being downloaded and aren't appearing in the External Libraries tab. That said, Clear itself uses some of the same libraries (LWJGL3) so is it that it's just making sure they aren't duplicated? Either way, the code itself is drawing red lines because it can't find the LWJGL3 libraries.
Does anyone know ways to fix these issues? Thanks in advance.
I managed to fix both of these problems myself.
To solve the first problem of using another project as a dependency, I was able to use the maven attributes of the projects to do so. I referenced Clear in ClearDialogue's pom file like this:
.
Then I opened the Maven view (View -> Tool Windows -> Maven) and added the pom files from Clear's own modules to the list along with the needed modules within the project itself:
.
After this I pressed the "Reimport all Maven Projects" button (the button in the picture above that looks like a refresh button) and rebuilt the project (Build -> Rebuild Project). This successfully downloaded all of my needed libraries and successfully added the local libraries from my own projects only available on the machine as well. With that I was able to successfully run to program as well.
As for the second half of my problem, I was able to find this answer from another question here on Stack Overflow, which coincidentally was how I was able to figure out how to add local dependencies as well.
I'm fairly new to using JavaFX and have been tinkering with it on my own in a few simple projects.
I have to collaborate with a few others for a main project, where I am seeing this conflicting issue:
I'm having an issue with the src.zip file of javafx. On my standalone projects, I do not encounter this issue. However, since working with others, this error has appeared. Prior to this, I was getting a Kotlin plugin issue, where I had to completely disable Kotlin.
Error:java: C:\Users\nolan\Javalibs\javafx-sdk-11.0.2\lib\src.zip
I'm unsure of what this issue might mean, so any help would be appreciated.
Thank you.
I had the same problem too and discovered it was because I added the JavaFX 11 SDK to Intellij incorrectly. I initially had the added library point to just the directory /lib. Since this directory includes both the jars and src.zip, Intellij will try to run both and produce the error.
To solve this, when Intellij prompts you to "Select Library Files," you need to explicitly select the files within the /lib directory which will then be added as shown here. This will also allow proper inspection of the source code without Intellij having to decompile the class file when ctrl + left clicking a class name.
Figured this out. I extracted the src.zip in the appropriate directory (deleting the zip as well), then had to change my VM Path to include:
--module-path "C:\yourpathto\javafx-sdk-11.0.2\lib;out\production" --add-modules=javafx.controls,javafx.fxml
I forgot to add ;out\production to the Module path.
A quick rebuild then solved this issue.
I currently have two projects. One being my main project which is TOMCAT/JSP and the second project being a jar library I'm working on.
The project I'm making a jar out of is fairly straight forward and after initally building/making and having it output a .jar file I went to the library section of the main project and pointed to it. Everything worked as expected until I tried to add additional functionality to the jar.
In that second project I added a new field to an enumeration. Now when trying to access it in the main project I'm getting the error in my TOMCAT log.
java.lang.NoSuchFieldError: MY_NEW_FIELD
I've tried deleting the jar from the output, removing the link from the library and rebuilding. Nothing seems to fix it. Is there something similar to "clean" that I can use to resolve this, or is there something else I need to do?