How to create a JavaFX module in IntelliJ IDEA - intellij-idea

I would like to integrate a JavaFX GUI in an existing IntelliJ IDEA Java project (java version 1.8.0_20).
Although I can create a JavaFX project from scratch (JavaFX plugin is enabled) in my IDE, I can't figure out how to create a module.
Do I need to define a new module SDK for a new Java module? Or does the type of the JavaFX module has to be IntelliJ Platform Plugin? I tried both without any success. Please help.
Many thanks,
Cristina

Update for Idea 2021.3
The previous information on this answer for Idea 13.1 is now outdated.
For Idea 2021.3, create a new JavaFX project using an Idea wizard:
New JavaFX project wizard.
From the main menu, select File | New | Project.
In the New Project wizard, select JavaFX from the list on the left.
I advise you follow the detailed instructions for creation and execution of JavaFX project at the new JavaFX project wizard link supplied.
A new JavaFX project created this way will be different from creating a new Java project using the same wizard. The new JavaFX project will be configured to use a build tool (e.g. maven or gradle). It will have the JavaFX module dependencies defined and will include sample code for a modular HelloWorld JavaFX FXML application. It is the perfect thing to use to get started with a new JavaFX application IMO.
If you want a new Idea module rather than a new project, then you just follow the same steps as above, but instead of selecting File | New | Project, you select File | New | Module, then select JavaFX from the list on the left as before.
Alternatively, you can create new modules in Idea by defining the modules in a Maven or Gradle project and importing the build tool project file for the project into Idea.
Prior answer for Idea 13.1
I don't think you can define a new JavaFX module in Idea 13.1. Note that there is not much difference between a JavaFX project and a non-JavaFX project in Idea, so you can just create a normal Java module and make a couple of manual tweaks to the module configuration and it should behave the same as if you created a JavaFX project. See the following answer for more details:
How to convert a normal java project in intellij into a JavaFx project

Okay this question is old and has been answered but let me add more to it. I came across the same problem and did a little workaround:
You first open the main project in IDEA (in which you want to add a JavaFX project module), then goto File -> New -> Project.
From there, you get the standard New Project dialog of IDEA, so select javaFX and proceed. Make sure the project location is where you want the JavaFX module to be created (which is why i prompted you to open the parent project in IDEA first). Open it in a new window and close it, doesn't matter.
Now, (Assuming that you only have the main project opened in IDEA) goto its File -> Project Structure and in the dialog, goto Modules and click add (+) -> Import module and then select the project you just created. Proceed through the wizard, overwrite the .iml and the JavaFX module should be added to your main project structure.

Related

Create GWT project in Intellij IDE

I'm beginner in using IntelliJ IDEA IDE and I want to create a new GWT project. I have added the GWT plugin to IntelliJ IDEA and now and I want to create a project. I googled but I didn't find a helpful tutorials or examples. Did you have guys a helpful tutorials to start. Thanks in advance.
Do not use the GWT project builders from IntelliJ or Eclipse. Both generate projects which use the same class path for client and server. In todays GWT development it is common to use a separate class path for client and server.
Depending on the server you prefer to use, choose:
https://github.com/tbroyer/gwt-maven-archetypes
in case you want to use Jetty or Tomcat on the server side or:
https://github.com/NaluKit/gwt-maven-springboot-archetype
in case you want to use Spring Boot.
How to create a new GWT project in IntelliJ
Create a new project: File → New... → Project...
Select Java EE (Legacy).
Select Java 8.
Do not use Java 9 or above unless you know what you're doing. Yes, GWT 2.8.2+ works with Java 11+, but you'll need to open some internal modules for it to work. If you just want to learn GWT, stay with Java 8.
In Additional Libraries and Frameworks, check ☑ Google Web Toolkit.
In GWT SDK, fill in the path to your GWT installation.
Check ☑ Create sample application and introduce a fully qualified class name for the main class.
Click Next, and fill in the rest of needed info for your new project (this has nothing to do with GWT).
You'll end up with something like this:
If you followed the steps closely, the sample project should be fully functional. IntelliJ should've created a Run configuration for you, too, so you can run the GWT app right away and see it in action:
This is all explained in the official help documentation for IntelliJ 2020.1, which was the last version to include GWT support out of the box.

Can't load the main class/runnable jar JavafX 8 project [duplicate]

i created a Javafx project using JDK 8 and when i tried to export it to a runnable .jar file, i got surprised that it doesn't run using CMD, and gives the following error :
"Javafx compenents are missing"
while it works perfectly during the compiling time(using the IDE) when i accessed the .jar files, i found it has just .class files (that i made), and the needed library files that haven't been exported (i made sure to select the "extract need library files extract required libraries into generated jar" option in Eclipse), is there a reason behind of this? and a way to solve it? thanks in advance
Ps: i tried this using Eclipse and Intellij IDE
I just wanna mention once again that I'm using JDK 8 where it has JavaFX library inside of it.
Did you try this?
There are detailed instructions on how to configure your IDE to run JavaFX with newer OpenJDKs (which do not come with JFX components in it).
It also explains how to create a new JavaFX Maven project from archetype, with all the necessary plugins to easily build your application while including the minimal Java components for it (using jlink).
This will ensure that anybody using your application will have those components.

Netbeans 11 how to add a library to a project when "Libraries" node is missing?

I am trying to run a simple java fx example with Maven on Netbeans 11 with openjdk 11. I followed the OpenJfx tutorial up to the creation of JavaFx as a global library.
But then when I want to add this global library to my project, the "libraries" node is missing in the project properties menu ?
How can I have this Libraries node present in the menu ? Or is there another way to add a global library to a project ?
Any help appreciated,
Indeed I was following the part of OpenJfx tutorial that creates an Ant project, whereas I was creating a Maven project.
If instead I use an Ant project, then the "libraries" node appears.
But the interesting part for Maven is further down. And there they write to create a Maven project from archetype.
Eventually it is working !

How to properly import a Play 2+ project in IntelliJ 14+ with all integrated features (run, debug, test)?

I work on a Java based Play! project for severals months now and I'd like to import it completely in IntelliJ, meaning being able to run, compile, test and debug from IntelliJ, without the need to use the command line.
According to this post from Jetbrain, it seems to be possible, if I quote the article it says clearly : "Now you don’t need to switch between IntelliJ IDEA and Play console anymore. Everything is available right from your favorite IDE.", but I can't figure out a way to achieve this for now, even if I follow the tutorial provided by Jetbrains.
Here are the steps I've been throught :
Open my fav IDE IntelliJ ;)
Go to the project list window.
Import project
Import from external model and choose SBT as suggested in Jetbrains tutorial.
option "Use auto import" checked, option "create directories for empty content roots automatically" checked. Project SDK Java 1.7
Global sbt settings : JVM From project JDK.
Finish
By now, if I try to make the project and launch it from IntelliJ, I'll get scala compiling errors related to routes object. Thanks to this post, we can understand that this happens because scala routes are located to specific folders that needs to be included in IntelliJ sources settings for this project. So next step was :
File -> Project Structure -> Modules
Add target/scala-2.10/classes:target/scala-2.10/resources_managed:target/scala-2.10/src_managed as sources folders.
But my problem remains the same, routes object being unrecognized.
Notes : I have no scala facets in my project structure configuration nor can add one.
IntelliJ provides integrated support for the Play Framework for Scala and Java. Support is currently only available in IntelliJ Ultimate Edition (see the Frameworks and Technology section).
Assuming Ultimate Edition, the setup for Play is incredibly easy. Simply create a new project by importing build.sbt, then choose Add Framework Support and choose Play 2.
Once complete, you can start and stop Play using the Play 2 Run/Debug configuration. No command line necessary.
Here is a more in depth look at IntelliJ's Play project configuration.
You could try the command play idea if you are using play or activator idea if you are using activator. That will do the magic.

Why does Eclipse load all plugins in a workspace?

I'm using Eclipse 3.6 for developing Eclipse plug-in. In the same workspace, I have 2 Plug-in projects: projA and projB. No mater which project was run, both two projects will be loaded in the new Eclipse instance. If I only want to load projA, I have to close projB, why?
I run the project like this: right click the project and "Run as--- Eclipse Application".
Have you defined the target platfom?
You can also edit your Run Configuration and choose the plugins to launch with.
The way you debug your project will start a new instance of Eclipse with all existing plugins installed(in your case,both project A and B are installed).This is typically called self-hosting in PDE.
If project A has no dependent package,just close other projects.