You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@netbeans.apache.org by Michael Bien <mb...@gmail.com> on 2024/09/17 01:40:51 UTC

Re: JEP 477

I re-tested this with soon-to-be-released NB 23 and it is working much 
better now due to #7637, #7605 and likely others.

void main(String[] args) {
     println("args: " + String.join(", ", args));
     println("prop=" + System.getProperty("prop"));
     println(Runtime.version());
}

the base module seems to be imported automatically by javac. The 
"unnamed main class" feature does not support package declarations, so 
the file has to be in the default package for this to work.

If you use this as "java script" outside any project context, select JDK 
23 in the file properties and check that the JVM args set --enable-preview.

In context of a project (tested using maven), simply select JDK 23 and 
set target to 23 in the project settings, you might have to bump the 
maven-compiler-plugin to the latest version.

In both cases: If you type something which requires a preview flag and 
javac notices this, a in-editor hint should appear which can add the 
required flags to the project/file config.

another tip:
don't put "java scripts" into the base of your home folder or other 
roots, since NB might start scanning the entire folder (due to the 
implicit multi-file source launcher classpath) which could take a while. 
A subfolder like ~/programs is fine though. This should get better with 
#7733 which didn't make it into NB 23 though.


a lot of JEP 477 didn't work last time I tried due to NPEs within javac, 
#7637 helped with that.

best regards,
michael


On 30.07.24 22:15, Michael Bien wrote:
> I don't think the third preview was implemented, but the second 
> preview worked already in NB 22 (no default imports and no module 
> imports).
>
> -mbien
>
> On 30.07.24 18:10, Kenneth Fogel wrote:
>> I downloaded and compiled the most recent NetBeans 23 build and am 
>> using an early access JDK 23. I wish to run the classic JEP  477 
>> example:
>>
>> import module java.base;
>>
>> void main() {
>>      println("Moose");
>> }
>>
>> (I really do not like "Hello World!" but that's my problem.)
>>
>> I suspect that I have missed a place to add the -enable-preview and 
>> -source 23 so that it can run.
>>
>> Is this feature supported by NetBeans?
>>
>> Ken
>>
>>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@netbeans.apache.org
For additional commands, e-mail: dev-help@netbeans.apache.org

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