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


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

Re: Using main from abstract class in concrete class

Path csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From Andreas Leitgeb <avl@logic.at>
Newsgroups comp.lang.java.programmer
Subject Re: Using main from abstract class in concrete class
Date Sun, 13 Aug 2017 10:59:26 -0000 (UTC)
Organization A noiseless patient Spider
Lines 16
Message-ID <slrnop0cga.o2q.avl@logic.at> (permalink)
References <87h8xbx0ig.fsf@munus.decebal.nl>
Reply-To avl@logic.at
Injection-Date Sun, 13 Aug 2017 10:59:26 -0000 (UTC)
Injection-Info mx02.eternal-september.org; posting-host="c9f2ba19e1c5daa470c6851ce1636ea3"; logging-data="14277"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19lB3adENHfvzM3RPyx6uPz"
User-Agent slrn/1.0.2 (Linux)
Cancel-Lock sha1:j2S3mW5fil1e60TYEACO34Zu9A8=
Xref csiph.com comp.lang.java.programmer:37173

Show key headers only | View raw


Cecil Westerhof <Cecil@decebal.nl> wrote:
> I have an abstract class. There can be several concrete classes that
> extend this class. Is it possible to write a main in the abstract
> class which will be used by the concrete classes and that in the main
> a instance of the concrete class is created?

The first part of the question is trivially yes: derived classes that
don't provide their own main() will get your "abstract" class's main().
I guess, you knew that already.

For the other part,
https://stackoverflow.com/questions/939932/how-to-determine-main-class-at-runtime-in-threaded-java-application
seems to imply that short of some non-reliable environment variables
or system properties there is no reliable way to know which class was
originally started.

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


Thread

Using main from abstract class in concrete class Cecil Westerhof <Cecil@decebal.nl> - 2017-08-13 11:47 +0200
  Re: Using main from abstract class in concrete class Andreas Leitgeb <avl@logic.at> - 2017-08-13 10:59 +0000
    Re: Using main from abstract class in concrete class Andreas Leitgeb <avl@logic.at> - 2017-08-13 11:38 +0000
  Re: Using main from abstract class in concrete class Cecil Westerhof <Cecil@decebal.nl> - 2017-08-13 15:43 +0200
  Re: Using main from abstract class in concrete class Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-08-13 10:32 -0400
    Re: Using main from abstract class in concrete class Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-08-13 10:37 -0400
    Re: Using main from abstract class in concrete class Cecil Westerhof <Cecil@decebal.nl> - 2017-08-13 17:17 +0200
      Re: Using main from abstract class in concrete class Andreas Leitgeb <avl@logic.at> - 2017-08-17 18:56 +0000
        Re: Using main from abstract class in concrete class Cecil Westerhof <Cecil@decebal.nl> - 2017-08-18 06:37 +0200
          Re: Using main from abstract class in concrete class Andreas Leitgeb <avl@logic.at> - 2017-08-18 19:48 +0000
            Re: Using main from abstract class in concrete class Cecil Westerhof <Cecil@decebal.nl> - 2017-08-18 23:37 +0200
              Re: Using main from abstract class in concrete class Cecil Westerhof <Cecil@decebal.nl> - 2017-08-19 01:32 +0200
  Re: Using main from abstract class in concrete class Joshua Cranmer 🐧 <Pidgeot18@verizon.invalid> - 2017-08-13 12:03 -0500

csiph-web