Add Java FX 2.0 to existing Netbeans project - java

I have an existing Java project in Netbeans that uses Swing and I would like to start using Java FX 2.0 for some components in that project.
I have dowloaded the latest version of the JDK (1.7.0_03) and enabled JavaFX but when I try adding an import javafx.xxx statement, Netbeans can't resolve the link. Do I need to manually add some JARs to my list of external libraries?
Project Properties use "JDK 1.7-FX Enabled":
which is configured this way:

If you created your project in older NetBeans it can miss libraries from FX enabled plaftorm.
You can:
either recreate the project in NetBeans 7.1+ and copy sources
or include next library to the libs: C:/Program Files/Oracle/JavaFX 2.0 SDK/rt/lib/jfxrt.jar

Related

How to add JavaFX to maven-based project in NetBeans

I opened a project in NetBeans, it is a Maven-based project and i have a problem with javafx imports. There is a communique f.e.: "package javafx.animation does not exist".
Normally when I create a new JavaFX projekt I select the Java with Ant > Java Aplication and then when I right click on my project on the projects list I choose Properties and in the Libraries section I can add JavaFX library.
In this case, when I open maven-based project there is not Libraries section in the properties and I don't know how to add the JavaFX library?
Instructions for using JavaFX with Maven and Gradle-based projects are found here:
https://openjfx.io/openjfx-docs/
I suspect you are running on a JDK that does not have JavaFX modules included. That is normal. However, there are some builds of OpenJDK that include the JavaFX modules so you don't have to add them manually. Using such a JDK may make things easier.
Consider one of the OpenJDK builds from Azul or Bellsoft that includes JavaFX.
For Bellsoft choose the "Full JDK":
https://bell-sw.com/pages/downloads/
For Azul choose "JDK FX" as the "package":
https://www.azul.com/downloads/zulu-community/?package=jdk

Eclipse 4-10 64bit: Cannot resolve SWT library

I try to get started with Eclipse 4-10 and SWT, but importing the SWT Library
in the java project doesn't work.
Here is what I did:
Download Win 64bit Version of Eclipse 2018-12 and SWT library from here:
https://download.eclipse.org/eclipse/downloads/drops4/R-4.10-201812060815/
use the Eclipse internal Installer to download and install "SWT Designer" with all it's dependencies from 2018-12 - http://download.eclipse.org/releases/2018-12
import the SWT-library-zip-file to the workspace via "File"->"Import"->"Existing projects into workspace"...
create a new java project, called testproject
get to testprojects "Properities"->"Java Build Path"->Tab "Projects"->Select "Classpath"->"Add"->select the org.eclipse.swt
Create an Application Window in my testproject via "create new visual classes"->"SWT"->"Application Window", called testwindow
But the import statements in the testwindow.java still show "the import org.eclipse cannot be resolved".
The setup process is according to the official eclipse site: https://www.eclipse.org/swt/eclipse.php
I use Windows 10 64bit, eclipse and SWT are both 64bit-versions too.
What am I missing?
In case you have a module-info.java file in the default package, delete it.
Having a module-info.java file enables the optional use of the Java Platform Module System (JPMS) which requires to specify all required modules.
Instead of deleting module-info.java you can also:
In the Java Build Path move the org.eclipse.swt project from the Classpath to the Modulepath
In module-info.java add the line requires org.eclipse.swt;

Eclipse: load my own JAR file before an Eclipse plugin

I want to use the latest version of org.json in my Google App Engine project. My project uses GWT plugins, which provide their own, older version of org.json, so if I put my json.jar file into WEB-INF/lib it gets ignored. If I go to the Eclipse project's Properties > Java Build Path > Libraries to remove the GWT JDK jar the project won't compile. If I use the same properties tab to add my own json.jar to the list of libraries (via Add Jars...) it doesn't help.
Is there anything I can do, or am I stuck with the older version of org.json?
EDIT: I'm not using Maven.
GWT no longer uses org.json since 2.7, so all you'd have to do is use an up-to-date version.
That said, even with GWT 2.6.1 or older, you should be able to:
compile against your more recent version of org.json by putting it above the GWT JDK in Properties > Java Build Path > Order and Export
run with your more recent version of org.json by putting into WEB-INF/lib. If that's not enough, you'll maybe have to remove gwt-servlet-deps.jar (which contains org.json classes) and replace it with validation-api-1.0.0.GA.jar. That however will only with GWT 2.6; with an even-older version you're out of luck (but 2.6.0 is almost 2 years old already, and 2.5.0 3 years old, that's an eternity at web scale)

Build swing project using the JavaFX Browser / WebEngine (Gradle)

I'm trying to build an application using the JavaFX WebEngine inside of a swing gui. Gradle complains about not finding the JavaFX packages. How can I tell gradle to include the appropriate jar?
I assume you are using jdk 7. Add the jfxrt.jar from your jre/lib directory to the build as a file dependency, or install it into your repository. This is not necessary if you are compiling with jdk 8.
You might also have to put new JFXPanel() at the beginning of your Swing app to start the JavaFX thread.
There is also a gradle-javafx plugin that is recommended. https://bitbucket.org/shemnon/javafx-gradle

Hibernate Classes Not Importing with Eclipse Juno and GWT: LockMode, SessionFactory, Criterion

Environment
Ubuntu 12.04 LTS
Eclipse Juno 4.2 Build id: 20120614-1722
GWT SDK - 2.4.0
App Engine SDK - 1.7.2
Hibernate Version 3.5
JRE: java-7-openjdk-amd64
In reference to #mael comment, Hibernate Tools was installed from the following Eclipse repo:
http://download.jboss.org/jbosstools/updates/stable/indigo/
Problem
The project is a GWT Web Application that uses Hibernate as the entity/persistence manager. I have successfully configured Hibernate to connect to the database, and it pulls in all the tables and associated columns I am interested in. I use Hibernate to reverse engineer the entity/persistence classes; it runs successfully, but I get the import errors in the newly generated classes:
The import org.hibernate.LockMode cannot be resolved.
The import org.hibernate.SessionFactory cannot be resolved.
The import org.hibernate.criterion.Example cannot be resolved.
Research/Troubleshooting
There was similar problem I found here. I performed the search for the aforementioned classes, and did not find them. I then readded java-7-openjdk-amd64 JRE under Windows > Preferences > Installed JREs. This did not resolve the problem.
Also, there does not seem to be very much out there for this problem. So I am assuming there is something I have not understood in the setup of Hibernate and reverse engineering.
Another Similar Problem - Same Solution
Update: Solution
Following #mael's solution, I confirmed that Hibernate Tools does not automatically include the Hibernate jar files required for the auto-generated entity/persistence classes.
Downloaded the Hibernate4 jar files from the following location.
Extracted files to the Eclipse workspace.
In Eclipse, right-click on {Project} and go to Build Path > Configure Build Path... > Java Build Path.
Click on the Libraries tab.
Click on Add External JARs...
Go to directory where Hibernate4 JAR files were extracted, and follow the path to lib > required.
Select all JAR files in the folder and confirm.
You may want to check your eclipse Build Path.
Right-click your project and navigate Build Path>Configure Build Path and in the tab libraries look for the Hibernate library, if you do not see it then download the jars manually or optionally use maven or ant to do this.
I don't remember if Hibernate Tools incorporates the Hibernate jars in the eclipse set of libraries. But if it doesnt, it should I guess.

Categories

Resources