• Surprise!

    From Jeff Higgins@21:1/5 to Stefan Ram on Sun Apr 26 05:06:48 2020
    On 9/19/19 3:28 PM, 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!

    .



    https://docs.oracle.com/en/java/javase/14/docs/specs/man/java.html#using-source-file-mode-to-launch-single-file-source-code-programs

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Martin Gregorie@21:1/5 to Jeff Higgins on Sun Apr 26 13:00:20 2020
    On Sun, 26 Apr 2020 05:06:48 -0400, Jeff Higgins wrote:

    On 9/19/19 3:28 PM, 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,

    Not here. I rearranged your source because I prefer opening and closing brackets to align. Here's the result:

    $ cat Main.java
    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!" );
    }
    }

    $ javac -version
    javac 1.8.0_242

    $ javac Main.java
    Main.java:1: error: class A is public, should be declared in a file named A.java
    public final class A
    ^
    Main.java:9: error: class B is public, should be declared in a file named B.java
    public final class B
    ^
    2 errors

    This is using Open Java 1.8 installed from the RedHat Fedora 31 package repository and is exactly what I'd expect to see, since the name of a non- nested class declaration should match the sourcefile name.


    --
    Martin | martin at
    Gregorie | gregorie dot org

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Joerg Meier@21:1/5 to Martin Gregorie on Mon Apr 27 09:13:59 2020
    On Sun, 26 Apr 2020 13:00:20 -0000 (UTC), Martin Gregorie wrote:

    On Sun, 26 Apr 2020 05:06:48 -0400, Jeff Higgins wrote:
    On 9/19/19 3:28 PM, Stefan Ram wrote:
    [...] with a recent JDK. [...]

    This is using Open Java 1.8 [...]

    Calling 1.8 "recent" is quite a stretch ;)

    Liebe Gruesse,
    Joerg

    --
    Ich lese meine Emails nicht, replies to Email bleiben also leider
    ungelesen.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Martin Gregorie@21:1/5 to Joerg Meier on Mon Apr 27 12:12:54 2020
    On Mon, 27 Apr 2020 09:13:59 +0200, Joerg Meier wrote:

    On Sun, 26 Apr 2020 13:00:20 -0000 (UTC), Martin Gregorie wrote:

    On Sun, 26 Apr 2020 05:06:48 -0400, Jeff Higgins wrote:
    On 9/19/19 3:28 PM, Stefan Ram wrote:
    [...] with a recent JDK. [...]

    This is using Open Java 1.8 [...]

    Calling 1.8 "recent" is quite a stretch ;)

    True enough, but AFAIK its still supported, alongside 11 and 14, for
    Fedora Linux. I recently saw stats (in The Register) showing the majority
    of developers are still using 8, and #242 is the most recent Java 8
    release.

    If its just as easy to move from Java 8 to 11 or 14 as it still is to
    compile a K&R source file under that latest ANSI C compiler, then I'm
    happy to move on, but is it that easy? Somehow I've gotten the impression
    that it may not be.


    --
    Martin | martin at
    Gregorie | gregorie dot org

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?Arne_Vajh=c3=b8j?=@21:1/5 to Martin Gregorie on Mon Apr 27 08:34:35 2020
    On 4/27/2020 8:12 AM, Martin Gregorie wrote:
    On Mon, 27 Apr 2020 09:13:59 +0200, Joerg Meier wrote:
    On Sun, 26 Apr 2020 13:00:20 -0000 (UTC), Martin Gregorie wrote:
    On Sun, 26 Apr 2020 05:06:48 -0400, Jeff Higgins wrote:
    On 9/19/19 3:28 PM, Stefan Ram wrote:
    [...] with a recent JDK. [...]

    This is using Open Java 1.8 [...]

    Calling 1.8 "recent" is quite a stretch ;)

    True enough, but AFAIK its still supported, alongside 11 and 14, for
    Fedora Linux.

    Yes. AdoptOpenJDK will supply updates until May 2026.

    https://adoptopenjdk.net/support.html

    I recently saw stats (in The Register) showing the majority
    of developers are still using 8,

    Yes. But a lot of them are in the process of upgrading to 11 now.

    If its just as easy to move from Java 8 to 11 or 14 as it still is to
    compile a K&R source file under that latest ANSI C compiler, then I'm
    happy to move on, but is it that easy? Somehow I've gotten the impression that it may not be.

    Java upgrades are usually pretty easy.

    But some can cause a bit of work.

    1.4 -> 1.5 was one of them.

    8 -> 11 is one of them.

    Things to be aware of include:
    * if you use unsupported SUN classes then you may need ti
    circumvent the module system introduced in Java 9 to
    get your stuff to build and run
    * if you use JAX-WS or JAXB then that is now a
    separate download - it is no longer builtin
    Java SE
    * if you use JavaFX then that is now a
    separate download - it is no longer builtin
    Java SE
    * if you use CORBA then you need to find
    another implementation

    But if you get JAX-WS and JAXB then my guess is that 99.8% of all
    Java 8 code will work with 11.

    Arne

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Eric Douglas@21:1/5 to Martin Gregorie on Mon Apr 27 06:36:37 2020
    On Monday, April 27, 2020 at 8:13:04 AM UTC-4, Martin Gregorie wrote:
    Calling 1.8 "recent" is quite a stretch ;)

    True enough, but AFAIK its still supported, alongside 11 and 14, for
    Fedora Linux. I recently saw stats (in The Register) showing the majority
    of developers are still using 8, and #242 is the most recent Java 8
    release.

    If its just as easy to move from Java 8 to 11 or 14 as it still is to
    compile a K&R source file under that latest ANSI C compiler, then I'm
    happy to move on, but is it that easy? Somehow I've gotten the impression that it may not be.


    --
    Martin | martin at
    Gregorie | gregorie dot org

    I'm using 8 right now. It is easy enough to move from 8 to 11 (when is the next LTS?) but getting government approval?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?Arne_Vajh=c3=b8j?=@21:1/5 to Eric Douglas on Mon Apr 27 09:46:56 2020
    On 4/27/2020 9:36 AM, Eric Douglas wrote:
    On Monday, April 27, 2020 at 8:13:04 AM UTC-4, Martin Gregorie wrote:
    Calling 1.8 "recent" is quite a stretch ;)

    True enough, but AFAIK its still supported, alongside 11 and 14, for
    Fedora Linux. I recently saw stats (in The Register) showing the majority
    of developers are still using 8, and #242 is the most recent Java 8
    release.

    If its just as easy to move from Java 8 to 11 or 14 as it still is to
    compile a K&R source file under that latest ANSI C compiler, then I'm
    happy to move on, but is it that easy? Somehow I've gotten the impression
    that it may not be.

    I'm using 8 right now. It is easy enough to move from 8 to 11 (when is the next LTS?) but getting government approval?

    It has changed a bit, but right now my understanding is that
    17 (September 2021) will be next LTS.

    Arne

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Martin Gregorie@21:1/5 to All on Mon Apr 27 13:52:56 2020
    On Mon, 27 Apr 2020 08:34:35 -0400, Arne Vajhøj wrote:

    On 4/27/2020 8:12 AM, Martin Gregorie wrote:
    On Mon, 27 Apr 2020 09:13:59 +0200, Joerg Meier wrote:
    On Sun, 26 Apr 2020 13:00:20 -0000 (UTC), Martin Gregorie wrote:
    On Sun, 26 Apr 2020 05:06:48 -0400, Jeff Higgins wrote:
    On 9/19/19 3:28 PM, Stefan Ram wrote:
    [...] with a recent JDK. [...]

    This is using Open Java 1.8 [...]

    Calling 1.8 "recent" is quite a stretch ;)

    True enough, but AFAIK its still supported, alongside 11 and 14, for
    Fedora Linux.

    Yes. AdoptOpenJDK will supply updates until May 2026.

    https://adoptopenjdk.net/support.html

    I recently saw stats (in The Register) showing the majority
    of developers are still using 8,

    Yes. But a lot of them are in the process of upgrading to 11 now.

    If its just as easy to move from Java 8 to 11 or 14 as it still is to
    compile a K&R source file under that latest ANSI C compiler, then I'm
    happy to move on, but is it that easy? Somehow I've gotten the
    impression that it may not be.

    Java upgrades are usually pretty easy.

    But some can cause a bit of work.

    1.4 -> 1.5 was one of them.

    8 -> 11 is one of them.

    Things to be aware of include:
    * if you use unsupported SUN classes then you may need ti
    circumvent the module system introduced in Java 9 to get your stuff
    to build and run
    * if you use JAX-WS or JAXB then that is now a
    separate download - it is no longer builtin Java SE
    * if you use JavaFX then that is now a
    separate download - it is no longer builtin Java SE
    * if you use CORBA then you need to find
    another implementation

    But if you get JAX-WS and JAXB then my guess is that 99.8% of all Java 8
    code will work with 11.

    Thanks, Arne.

    I don't use any of the gotchas you mention - nothing, really, outside the
    what was in the 1.6 standard library, apart from some 3rd party stuff:

    - the Coco/R syntax generator
    - RiverLayout,
    - a geodesy package,
    - dnsjava,
    - mail stuff (jaf ?, javamail, mstor)
    - jcharset
    - jdbc for PostgreSQL

    so it looks as though the move should be straight forward.


    --
    Martin | martin at
    Gregorie | gregorie dot org

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?Arne_Vajh=c3=b8j?=@21:1/5 to Martin Gregorie on Mon Apr 27 10:04:59 2020
    On 4/27/2020 9:52 AM, Martin Gregorie wrote:
    On Mon, 27 Apr 2020 08:34:35 -0400, Arne Vajhøj wrote:
    On 4/27/2020 8:12 AM, Martin Gregorie wrote:
    If its just as easy to move from Java 8 to 11 or 14 as it still is to
    compile a K&R source file under that latest ANSI C compiler, then I'm
    happy to move on, but is it that easy? Somehow I've gotten the
    impression that it may not be.

    Java upgrades are usually pretty easy.

    But some can cause a bit of work.

    1.4 -> 1.5 was one of them.

    8 -> 11 is one of them.

    Things to be aware of include:
    * if you use unsupported SUN classes then you may need ti
    circumvent the module system introduced in Java 9 to get your stuff
    to build and run
    * if you use JAX-WS or JAXB then that is now a
    separate download - it is no longer builtin Java SE
    * if you use JavaFX then that is now a
    separate download - it is no longer builtin Java SE
    * if you use CORBA then you need to find
    another implementation

    But if you get JAX-WS and JAXB then my guess is that 99.8% of all Java 8
    code will work with 11.

    I don't use any of the gotchas you mention - nothing, really, outside the what was in the 1.6 standard library, apart from some 3rd party stuff:

    - the Coco/R syntax generator
    - RiverLayout,
    - a geodesy package,
    - dnsjava,
    - mail stuff (jaf ?, javamail, mstor)
    - jcharset
    - jdbc for PostgreSQL

    so it looks as though the move should be straight forward.

    Give it a try.

    :-)

    Arne

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?Arne_Vajh=c3=b8j?=@21:1/5 to All on Mon Apr 27 10:09:07 2020
    On 4/27/2020 8:34 AM, Arne Vajhøj wrote:
    8 -> 11 is one of them.

    Things to be aware of include:
    * if you use unsupported SUN classes then you may need ti
      circumvent the module system introduced in Java 9 to
      get your stuff to build and run
    * if you use JAX-WS or JAXB then that is now a
      separate download - it is no longer builtin
      Java SE
    * if you use JavaFX then that is now a
      separate download - it is no longer builtin
      Java SE
    * if you use CORBA then you need to find
      another implementation

    But if you get JAX-WS and JAXB then my guess is that 99.8% of all
    Java 8 code will work with 11.

    They did try to avoid breaking things.

    This code actually works:

    public class NewStuff {
    public static void main(String[] args) {
    int var = 123;
    var i = 456;
    System.out.println(var + i);
    }
    }


    Arne

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)