question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Java 14 preview seems not to be working properly

See original GitHub issue

Hello,

I just set up a project and I need to try textblock. I wrote the following pom.xml:

<?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>com.kearny</groupId>
    <artifactId>rope</artifactId>
    <version>1.0-SNAPSHOT</version>
    <name>RopeTextEditor</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>14</maven.compiler.source>
        <maven.compiler.target>14</maven.compiler.target>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>14.0.1</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-maven-plugin</artifactId>
                <version>0.0.4</version>
                <configuration>
                    <source>14</source>
                    <target>14</target>
                    <release>14</release>
                    <mainClass>com.kearny.rope.RopeTextEditor</mainClass>
                    <commandlineArgs>--enable-preview</commandlineArgs>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

With the following java class only:

package com.kearny.rope;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

public class RopeTextEditor extends Application {

   @Override
   public void start(Stage stage) throws Exception {
       var javaVersion = System.getProperty("java.version");
       var javafxVersion = System.getProperty("javafx.version");
       var label = new Label("Hello, JavaFX " + javafxVersion + ", running on Java " + javaVersion + ".");
       var scene = new Scene(new StackPane(label), 640, 480);
       stage.setScene(scene);
       stage.show();

       Object test = """
               <html>
                   <body>
                       <p>Hello, world</p>
                   </body>
               </html>
               """;

       if (test instanceof String) {
           System.out.println(test);
       } else {
           System.out.println(test);
       }
   }

   public static void main(String[] args) {
       launch(args);
   }
}

I get this error: Error:(20,23) java: text blocks are a preview feature and are disabled by default.

Is there something wrong with my configuration ?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Kearnycommented, May 14, 2020

How I see, I was doing either one or the other. Not both (runtime and compile time). Thx for the help.

1reaction
betanzoscommented, May 14, 2020

This work for me.

<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-compiler-plugin</artifactId>
	<version>3.8.0</version>
	<configuration>
		<compilerArgs>
		    <!-- Required at compile time -->
                    <arg>--enable-preview</arg>
		</compilerArgs>
	</configuration>
</plugin>
<plugin>
	<groupId>org.openjfx</groupId>
	<artifactId>javafx-maven-plugin</artifactId>
	<version>0.0.4</version>
	<configuration>
		<options>
		    <!-- Required at runtime (javafx:run) -->
		    <option>--enable-preview</option>
		</options>
		<mainClass>gui/com.betanzos.App</mainClass>
	</configuration>
</plugin>
Read more comments on GitHub >

github_iconTop Results From Across the Web

JDK 14 + preview-features not working correctly #1167 - GitHub
Hello, our project uses maven with eclipse 4.16 and 4.17, latest greclipse release (also same on snapshot) java 14, groovy 3 and joint...
Read more >
"Records" preview feature in IntelliJ 2020.1 with Java 14 fails ...
"Records" preview feature in IntelliJ 2020.1 with Java 14 fails with compiler error during Maven `install`, but runs otherwise - Stack Overflow ...
Read more >
The role of preview features in Java 14, Java 15, Java 16, and ...
Preview features are specific to a given Java SE feature release and require the use of special flags at compile time as well...
Read more >
Java 14 and IntelliJ IDEA - The JetBrains Blog
Configure IntelliJ IDEA 2020.1 to use JDK 14 for Project SDK and choose the Project language level as '14 (Preview) – Records, patterns,...
Read more >
Evolving Java With ––enable–preview aka Preview Language ...
▚Eclipse. Open the Project Properties and go to Java Compiler. The panel on the right-hand side has a checkbox Enable preview features.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found