[ 
https://issues.apache.org/jira/browse/NETBEANS-4034?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17073670#comment-17073670
 ] 

Vedran commented on NETBEANS-4034:
----------------------------------

Sure,

1. First i create Maven application:

    File -> New Project -> Java with Maven -> Java Application

2. Then i create Java class in src/main/java/package_name directory

     New File -> Java -> Java Class

3.  In created class, i write psvm + tab to create main method

4. In created class i create static property

static String B = """
 test
 """;

5. Red hint shows saying:

text blocks are a preview feature and are disabled by default.
 (use --enable-preview to enable text blocks)
----
(Alt-Enter shows hints)

6. I click Alt+Enter while on create static property -> two options are shown:

Enable Preview Feature

Convert to String

7. I click on the Enable Preview Feature

8. Mouse over static property now shows (hint is no longer red):

Text block may not be supported
----
(Alt-Enter shows hints)

9. In main method i add: System.out.println(B);

10. Right mouse click on my project in Projects explorer

11. Mouse click on the Clean and Build produces: BUILD SUCCESS

12. Right mouse click on the opened class in editor and then Run File produces:

--- exec-maven-plugin:1.5.0:exec (default-cli) @ preview ---
Error: LinkageError occurred while loading main class hr.vs.preview.A
 java.lang.UnsupportedClassVersionError: Preview features are not enabled for 
hr/vs/preview/A (class file version 58.65535). Try running with 
'--enable-preview'
Command execution failed.
org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit 
value: 1)
 at org.apache.commons.exec.DefaultExecutor.executeInternal 
(DefaultExecutor.java:404)
 at org.apache.commons.exec.DefaultExecutor.execute (DefaultExecutor.java:166)
 at org.codehaus.mojo.exec.ExecMojo.executeCommandLine (ExecMojo.java:764)
 at org.codehaus.mojo.exec.ExecMojo.executeCommandLine (ExecMojo.java:711)
 at org.codehaus.mojo.exec.ExecMojo.execute (ExecMojo.java:289)
 at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo 
(DefaultBuildPluginManager.java:137)
 at org.apache.maven.lifecycle.internal.MojoExecutor.execute 
(MojoExecutor.java:210)
 at org.apache.maven.lifecycle.internal.MojoExecutor.execute 
(MojoExecutor.java:156)
 at org.apache.maven.lifecycle.internal.MojoExecutor.execute 
(MojoExecutor.java:148)
 at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject 
(LifecycleModuleBuilder.java:117)
 at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject 
(LifecycleModuleBuilder.java:81)
 at 
org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build
 (SingleThreadedBuilder.java:56)
 at org.apache.maven.lifecycle.internal.LifecycleStarter.execute 
(LifecycleStarter.java:128)
 at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
 at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
 at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
 at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
 at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
 at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
 at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
 at jdk.internal.reflect.NativeMethodAccessorImpl.invoke 
(NativeMethodAccessorImpl.java:62)
 at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke 
(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke (Method.java:564)
 at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced 
(Launcher.java:282)
 at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
 at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode 
(Launcher.java:406)
 at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 0.596 s
Finished at: 2020-04-02T14:08:11+02:00

 

13. Right mouse click on class in the Projects explorer and then Run File 
produces:

--- exec-maven-plugin:1.5.0:exec (default-cli) @ preview ---
Error: LinkageError occurred while loading main class hr.vs.preview.A
 java.lang.UnsupportedClassVersionError: Preview features are not enabled for 
hr/vs/preview/A (class file version 58.65535). Try running with 
'--enable-preview'
Command execution failed.
org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit 
value: 1)
 at org.apache.commons.exec.DefaultExecutor.executeInternal 
(DefaultExecutor.java:404)
 at org.apache.commons.exec.DefaultExecutor.execute (DefaultExecutor.java:166)
 at org.codehaus.mojo.exec.ExecMojo.executeCommandLine (ExecMojo.java:764)
 at org.codehaus.mojo.exec.ExecMojo.executeCommandLine (ExecMojo.java:711)
 at org.codehaus.mojo.exec.ExecMojo.execute (ExecMojo.java:289)
 at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo 
(DefaultBuildPluginManager.java:137)
 at org.apache.maven.lifecycle.internal.MojoExecutor.execute 
(MojoExecutor.java:210)
 at org.apache.maven.lifecycle.internal.MojoExecutor.execute 
(MojoExecutor.java:156)
 at org.apache.maven.lifecycle.internal.MojoExecutor.execute 
(MojoExecutor.java:148)
 at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject 
(LifecycleModuleBuilder.java:117)
 at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject 
(LifecycleModuleBuilder.java:81)
 at 
org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build
 (SingleThreadedBuilder.java:56)
 at org.apache.maven.lifecycle.internal.LifecycleStarter.execute 
(LifecycleStarter.java:128)
 at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
 at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
 at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
 at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
 at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
 at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
 at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
 at jdk.internal.reflect.NativeMethodAccessorImpl.invoke 
(NativeMethodAccessorImpl.java:62)
 at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke 
(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke (Method.java:564)
 at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced 
(Launcher.java:282)
 at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
 at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode 
(Launcher.java:406)
 at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 0.590 s
Finished at: 2020-04-02T14:10:39+02:00

> --enable-preview + VM Options problem on MacOS
> ----------------------------------------------
>
>                 Key: NETBEANS-4034
>                 URL: https://issues.apache.org/jira/browse/NETBEANS-4034
>             Project: NetBeans
>          Issue Type: Bug
>          Components: java - Compiler, java - Editor
>    Affects Versions: 11.3
>         Environment: Product Version: Apache NetBeans IDE 11.3
> Java: 14; OpenJDK 64-Bit Server VM 14+36-1461
> Runtime: OpenJDK Runtime Environment 14+36-1461
> System: Mac OS X version 10.15.3 running on x86_64; UTF-8; en_GB (nb)
>            Reporter: Vedran
>            Priority: Blocker
>
> Whatever i do i can't enable preview features in NetBeans. I also see hint 
> 'Text block may not be supported'. I uninstalled nb-javac and i am running 
> NetBeans on JDK 14. I also cleared cache. I can see that --enable-preview 
> flag is set in pom.xml and in VM Options.
> In terminal, java --enable-preview --source 14 A.java executes as expected.
> What i also noticed in previous versions of NetBeans is that VM Options 
> configured under Run are not passed to Maven.
> What am i missing?



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org
For additional commands, e-mail: commits-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to