<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>> import module java.base;<br>
><br>
> main() {<br>
><br>
> println("Moose");<br>
><br>
>}</p>
<p>It appears that you are missing a "void" return type before the
main() method name. As noted in the JEP-477, it should be:</p>
<p>import module java.base;<br>
void main() {<br>
println("Moose");<br>
}<br>
</p>
<p>-Jaikiran<br>
</p>
<div class="moz-cite-prefix">On 30/07/24 9:05 pm, <a class="moz-txt-link-abbreviated" href="mailto:omniprof@gmail.com">omniprof@gmail.com</a>
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:009e01dae296$2ced4550$86c7cff0$@gmail.com">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="Generator"
content="Microsoft Word 15 (filtered medium)">
<style>@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face
{font-family:Aptos;}p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
font-size:11.0pt;
font-family:"Aptos",sans-serif;
mso-ligatures:standardcontextual;
mso-fareast-language:EN-US;}a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#467886;
text-decoration:underline;}span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Aptos",sans-serif;
color:windowtext;}.MsoChpDefault
{mso-style-type:export-only;
font-size:11.0pt;
mso-fareast-language:EN-US;}div.WordSection1
{page:WordSection1;}</style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="WordSection1">
<p class="MsoNormal">I apologize for posting what is likely a
trivial question that may be inappropriate for this list but I
cannot find anywhere in my searches to explain what is going
wrong. Simply put JEP 477 does not work in the pre-release
version of Java 23 on a Windows 11 PC. There is a lot written
that all show a similar example.<o:p></o:p></p>
<p class="MsoNormal"><b><o:p> </o:p></b></p>
<p class="MsoNormal"><b>>> Here is the program<o:p></o:p></b></p>
<p class="MsoNormal">import module java.base;<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">main() {<o:p></o:p></p>
<p class="MsoNormal"> println("Moose");<o:p></o:p></p>
<p class="MsoNormal">}<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><b>>> Here is the version of Java I
am running<o:p></o:p></b></p>
<p class="MsoNormal">C:\dev\Onramptesting\OnRamptest\src>java
--version<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">openjdk 23-ea 2024-09-17<o:p></o:p></p>
<p class="MsoNormal">OpenJDK Runtime Environment (build
23-ea+34-2361)<o:p></o:p></p>
<p class="MsoNormal">OpenJDK 64-Bit Server VM (build
23-ea+34-2361, mixed mode, sharing)<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><b>>> Here I run the code with all
the required switches. The errors are the same with or
without Xlint<o:p></o:p></b></p>
<p class="MsoNormal">C:\dev\Onramptesting\OnRamptest\src>javac
--enable-preview --source 23 -Xlint:preview Main.java<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Main.java:1: warning: [preview] module
imports are a preview feature and may be removed in a future
release.<o:p></o:p></p>
<p class="MsoNormal">import module java.base;<o:p></o:p></p>
<p class="MsoNormal"> ^<o:p></o:p></p>
<p class="MsoNormal">Main.java:3: error: class, interface, enum,
or record expected<o:p></o:p></p>
<p class="MsoNormal">main() {<o:p></o:p></p>
<p class="MsoNormal">^<o:p></o:p></p>
<p class="MsoNormal">Main.java:5: error: class, interface, enum,
or record expected<o:p></o:p></p>
<p class="MsoNormal">}<o:p></o:p></p>
<p class="MsoNormal">^<o:p></o:p></p>
<p class="MsoNormal">2 errors<o:p></o:p></p>
<p class="MsoNormal">1 warning<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Note that I get the same results for
–source 23 and –release 23<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Trying single file:<o:p></o:p></p>
<p class="MsoNormal">java –enable-preview Main.java<o:p></o:p></p>
<p class="MsoNormal">does not work as well.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Same result using Console or PowerShell in
Windows.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">What am I doing wrong? <o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Ken Fogel<o:p></o:p></p>
<p class="MsoNormal"><a href="mailto:omniprof@gmail.com"
moz-do-not-send="true" class="moz-txt-link-freetext">omniprof@gmail.com</a><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</blockquote>
</body>
</html>