Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java 14 Syntax error on token "record", record expected

I'm engaged in building something in Java 14.

I wrote a class named for PersonInJava14 shown below.

package recordexample;

public record PersonInJava14(String name, String gender, int age) {}

However, it throws an error like this.

Syntax error on token "record", record expected

The project is based on Java 14 and can be done essential settings to run it in Java 14.

Here is my setting part.

enter image description here

How can I fix it ?

like image 581
S.N Avatar asked May 03 '26 09:05

S.N


1 Answers

It seems to be a problem with your Eclipse. You can download another version of Eclipse or try compiling it by console with the following command: javac.exe PersonInJava14.java --enable-preview

Hope you can solve you problem ;)

like image 179
Ciro Diaz Avatar answered May 05 '26 22:05

Ciro Diaz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!