Issue
Whenever I try to run my first and simple hello world JavaFX project on my 14 inch MacBook M1 Pro I see the following screen:
It seems a folder named java, only thing i can do is terminate the process from the eclipse console.
Here more images about the javaFX setup (seems all correct): I read a lot of different forums and they said that with the latest versione I should have all the libraries in the "Modulepath", however i tried all the different possibilities and no one seems work.
a window appears, not a folder
Solution
I just ran your code, without the line about stylesheets.
This code works. A small empty window appears in the middle of my screen.
package work.basil.example;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
public class ExEclipse extends Application
{
@Override
public void start ( Stage primaryStage )
{
try
{
BorderPane root = new BorderPane ( );
Scene scene = new Scene ( root , 400 , 400 );
primaryStage.setScene ( scene );
primaryStage.show ( );
}
catch ( Exception e )
{
e.printStackTrace ( );
}
}
public static void main ( String[] args )
{
launch ( args );
}
}
I used IntelliJ rather than Eclipse, but that really should not matter.
Though not related to your problem, I suggest adding some content to your pane. For example:
root.setCenter ( new Label ( "Hello World! " + Instant.now ( ) ) );
I ran this on Apple MacBook Pro, 16-inch, 2021, with Apple M1 Pro chip, macOS Ventura 13.6. Used the LibericaFX JDK from BellSoft, version 21.0.1.
My Maven POM file:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>work.basil.example</groupId>
<artifactId>PastedFX</artifactId>
<version>1.0-SNAPSHOT</version>
<name>PastedFX</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>21</maven.compiler.release>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.10.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.2.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.1</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.1.2</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>3.1.1</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.1.1</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>4.0.0-M3</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.4.1</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
More tips, but not related to your problem:
- Learn to use Maven (or Gradle) to manage your dependencies (external libraries) and your build process.
- Install a JDK that includes the JavaFX (OpenJXF) libraries. This is simpler than installing the OpenJFX libraries into your project. At least two of the several JDK vendors provide editions of the JDK offerings bundled with OpenJFX: Azul Systems and BellSoft. Both available conveniently through SDKMAN!.
Answered By - Basil Bourque
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.