Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #39149

Re: Surprise!

Newsgroups comp.lang.java.programmer
Date 2019-09-19 14:01 -0700
References <Main.java-20190919202538@ram.dialup.fu-berlin.de> <qm0pgn$h50$1@dont-email.me>
Message-ID <de9d18a6-87b9-4eb1-b320-e5bd01e69c62@googlegroups.com> (permalink)
Subject Re: Surprise!
From Eric Douglas <e.d.programmer@gmail.com>

Show all headers | View raw


On Thursday, September 19, 2019 at 4:47:31 PM UTC-4, Martin Gregorie wrote:
> On Thu, 19 Sep 2019 19:28:50 +0000, Stefan Ram wrote:
> 
> > Write this:
> > 
> > public final class A { public static void main( final java.lang.String[]
> > args )
> >   { B.hello(); }}
> > 
> > public final class B { public static void hello()
> >   { java.lang.System.out.println( "Hello!" ); }}
> > 
> >   and save it as "Main.java". Then call:
> > 
> > java Main.java
> > 
> >   with a recent JDK. What you have there is a file named "Main.java"
> >   that does /not/ contain a class "Main", and it has /two/ public
> >   classes. Yet, the above command will happily print,
> > 
> > Hello!
> > 
> >
> Not with the latest Open JDK 1.8 it doesn't: this just complains the A 
> should be on A.java and B should be in B.java
> 
> Maybe later Java versions removed the "ClassName == ClassName.java" and 
> "public static void main(String[])" requirements to make scripting easier?
> 
> 
> -- 
> Martin    | martin at
> Gregorie  | gregorie dot org

That does work on mine, using OpenJDK 11.0.4.11, though Eclipse still complains.

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Re: Surprise! Martin Gregorie <martin@mydomain.invalid> - 2019-09-19 20:47 +0000
  Re: Surprise! Eric Douglas <e.d.programmer@gmail.com> - 2019-09-19 14:01 -0700
    Re: Surprise! Martin Gregorie <martin@mydomain.invalid> - 2019-09-19 23:18 +0000
      Re: Surprise! Knute Johnson <groups@585ranch.com> - 2019-09-19 20:03 -0500
      Re: Surprise! Eric Douglas <e.d.programmer@gmail.com> - 2019-09-20 08:03 -0700
        Re: Surprise! Arne Vajhøj <arne@vajhoej.dk> - 2019-09-20 19:01 -0400

csiph-web