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


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

Re: "Hello world!" without a public class?

From "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org>
Newsgroups comp.lang.java.programmer
References <public-20130106091348@ram.dialup.fu-berlin.de> <-8CdnaTS2P6a5HTNnZ2dnUVZ8vOdnZ2d@bt.com> <startup-20130106143903@ram.dialup.fu-berlin.de>
Subject Re: "Hello world!" without a public class?
Date 2013-01-06 14:02 +0000
Message-ID <y72dncgdN-_lGXTNnZ2dnUVZ7tGdnZ2d@bt.com> (permalink)

Show all headers | View raw


Stefan Ram wrote:
> "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> writes:
> > students if you made that very clear to them from the start (yes, there
> > is a
>
>  I have no idea what you would prefer instead, but I just
>  made up this:
>
>  Rename »java.exe« (the JVM) to »new.exe« and modify the
>  interpretation of its command line arguments so that one can
>  write on the command line:
>
> new Main().start()

Or maybe (simpler, but less Java-like):

    javaNew.exe class-name method-name [arguments...]

Note that there's no need to mess with the JVM for these purposes, it only 
requires a special-purpose launcher program to replace java.exe.  The source to 
java.exe is provided, it's a simple JNI program, and is explicitly open for you 
to copy/modify/reuse without special licencing arrangements (at least that used 
to be true, haven't checked whether Oracle have changed anything).

But that might be overkill (however attractive).  Maybe simpler just to tell 
students always to write their entry-point in the form:

    class Xxx {
        public static void main(String args...)
        {
            new Yyy().doSomething();
        }
    }

(note that the entry-point class always contains main() and nothing else) and 
to treat that pattern as "magic".  Late in the course, after they've got a 
solid grounding in OO and (even later) you've talked about things like static 
methods (and why they are often a bad idea), you can explain what's going on 
with main().  With luck, by that point the students will be able to see that 
it's highly non-typical of Java code, and breaks several "rules", but (by then) 
you'll also be able to explain /why/ it's such a special case.

(All just ideas, of course, I am /not/ an educator, let alone an 
educationalist)

    -- chris 

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


Thread

Re: "Hello world!" without a public class? "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2013-01-06 13:09 +0000
  Re: "Hello world!" without a public class? "Aryeh M. Friedman" <Aryeh.Friedman@gmail.com> - 2013-01-06 05:19 -0800
    Re: "Hello world!" without a public class? "Aryeh M. Friedman" <Aryeh.Friedman@gmail.com> - 2013-01-06 05:28 -0800
      Re: "Hello world!" without a public class? lipska the kat <lipskathekat@yahoo.co.uk> - 2013-01-06 13:36 +0000
      Re: "Hello world!" without a public class? "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2013-01-06 13:44 +0000
        Re: "Hello world!" without a public class? Arne Vajhøj <arne@vajhoej.dk> - 2013-01-06 10:49 -0500
          Re: "Hello world!" without a public class? Arne Vajhøj <arne@vajhoej.dk> - 2013-01-06 11:45 -0500
          Re: "Hello world!" without a public class? Martin Gregorie <martin@address-in-sig.invalid> - 2013-01-06 19:44 +0000
            Re: "Hello world!" without a public class? Arne Vajhøj <arne@vajhoej.dk> - 2013-01-06 16:09 -0500
              Re: "Hello world!" without a public class? Martin Gregorie <martin@address-in-sig.invalid> - 2013-01-06 21:46 +0000
  Re: "Hello world!" without a public class? "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2013-01-06 14:02 +0000
  Re: "Hello world!" without a public class? "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2013-01-06 14:12 +0000
  Re: "Hello world!" without a public class? Arne Vajhøj <arne@vajhoej.dk> - 2013-01-06 10:42 -0500

csiph-web