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

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.

Related

Creating JAR of an application that uses OpenJavaFX 14 in IntelliJ. Does the Jar contain JavaFX runtime?

I used the latest things, OpenJDK14, and OpenJavaFX 14 in IntellJ. I created a simple sample JavaFX application that has a few buttons and a table, and a few lines of code to create the window. Now, as for "artifacts", choosing "JavaFx Application" did not work. According to existing answers on StackOverflow, that option no longer works because latest JDK does not include JavaFX. So, I used the regular "JAR" option with "from modules with dependencies".
The generated JAR file was huge. It was 15MB. And only 1KB of which is my code. The content of the JAR is like below. Since the JAR is very big, I thought that it includes the JavaFX runtime, too. But when I copied the JAR to another computer (Ubuntu) and tried to run it, it failed with a message saying that JavaFX is needed. So, I installed JavaFX and then in worked.
My question is, if the JAR does not include JavaFX runtime, why is it so big? Or is it that the JAR does include JavaFX runtime but I my settings for the JAR are wrong and the included runtime is not recognised on the other computer?

Configuring Intellij IDEA to work with Smartsheet-api sdk for java

I am setting up smartsheet SDK for Java, and running into problems trying to use it in IntelliJ IDEA. I am fairly unfamiliar with setting up decencies, modules, and such in IntelliJ, and am just looking for guidance on setting this up to work with Smartsheet SDK.
I'm currently using the Windows version with JDK13 (I also have JDk12). I've tried downloading the JAR file and pointing to that as a dependency, but it doesn't even understand the imports.
I would start with the Smartsheet Sample App for Java, which will already have the code in it for loading dependencies and libraries. https://github.com/smartsheet-samples/java-read-write-sheet

How to build jar with javafx in openjdk12

I'm trying to build jar for javafx desktop application. Working in IntelijIdea, jdk 12,using javafx12, link javafx sdk, write VM-options in menu run-edit configuration. In IDE all working correctly, my app launches and works. But when I try to create artifact and then build it to jar all brokes. IDE tell, that fx:deploy isn't there. Then my app don't work even in IDE.
I got stuck here.
Can you, please, help, how to build this javafx to launch it without IDE?
p. s. Know, that in jdk8, where javafx still includes, it's easier, but is it really no other way to create independent from IDE javafx, than using jdk8?
Built GUI with swing, created artifact and then built it to jar.
There wasn't problems.
But I don't want swing...
actual error: "Error. Java FX Packager: Can't build artifact - fx:deploy is not available in this JDK.
Will be really greatfull for tricks or tips with that.

Inspecting code on a non-java IntelliJ IDEA project

I'm using IntelliJ IDEA to build a non-java project, it is just a PHP + Javascript project, everything is working just fine but when I try to Inspect all the code in the project (Analyze -> Inspect Code) I get an error:
The JDK is not configured properly for this project. Inspection cannot proceed.
Am I doing something wrong? Do I have to configure an SDK even though the project is not java?
Note: The automatic code inspection for working files opened in the editor is working fine, the only problem is when I try to inspec all the code in the project.
Note 2: I cannot use PHPStorm neither Webstorm.
Thanks.
In my case, I didn't wanted to delete the module since I have a bunch of stuff configured (data sources, dictionaries, http requests) and a lot of code in the shelf (which I believe it's stored along the project/module). I found that you can skip the "delete your module" part and instead just update the module config:
Find the $module.iml file (in my case it's inside the .idea directory) and at the top there's was a line:
<module type="JAVA_MODULE" version="4">
which I changed to:
<module type="WEB_MODULE" version="4">
The issue was fixed and I haven't seen any side-effects but, just in case, you might want to backup the .idea directory.
I raised this over at https://youtrack.jetbrains.com/issue/IDEA-188017 - after some back and forth, the Jetbrains employee helped me figure out that I had a Java module in there.
If you are not using Java, please crate a module of a Static Web type. Now you have a module of a Java type, that is why the error is reported, so such behaviour is expected.
Delete your Java module.
Once you enter in the menu in the screenshot below, find the Static Web type and create your module like that.
Seems like adding a SDK the code analyzer works just fine, even though the project has no single java module.
Maybe it is a bug, so I will report it.
My project's .idea/<project>.iml file had an entry:
<orderEntry type="inheritedJdk" />
I quit Idea, removed the line above from the iml file, restarted Idea and the next Inspection ran without any issues.
I recently ran into this issue with my purely Python project.
After much frustation, I bumped into a rather bizarre solution:
When IntelliJ complained that JDK is not configured, in the following dialog box, I just selected JDK8 (instead of Python 3.7.2 path) and viola! its gone.
My environment was
IntelliJ IDEA 2018.3.4 (Community Edition)
Build #IC-183.5429.30, built on January 29, 2019
JRE: 1.8.0_152-release-1343-b26 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.14.2

Why does IntelliJ import extra libraries from JDK 1.6 for a simple hello world program?

I'm new to Java and IntelliJ and I am just doing a simple "hello world" program. IntelliJ has about 10+ libraries from JDK 1.6 added to my project even though I'm not importing anything in my classes that would seem to need them. I created a new project from scratch.
Some of the libraries are alt-rt.jar, charsets.jar, deploy.jar, dnsns.jar, javaws.jar, jce.jar, jsse.jar, localedata.jar, etc.
Can anyone explain why those libraries were added? Can I remove those libraries from the Module Settings/SDK with no ill effect?
They will be in the classpath anyways as they are part of the standard library. I'm not sure what will happen if you remove them, but you definitely don't need to do that.
These libraries aren't imported in your project, intelliJ has just parsed these jar to see what were the accessibles classes (for auto-completion) with the default classpath.
They won't be packaged with your project.
Plus as your JDK (or any SDK for what it worth) is defined for intelliJ and not for your project only, every project you will create in the future will use the already parsed data from your JDK.