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


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

How does it know?

From Knute Johnson <nospam@rabbitbrush.frazmtn.com>
Newsgroups comp.lang.java.programmer
Subject How does it know?
Date 2014-09-12 08:11 -0700
Organization A noiseless patient Spider
Message-ID <luv2fd$j58$1@dont-email.me> (permalink)

Show all headers | View raw


Give two classes:

public class test {
     public static void main(String... args) {
         System.out.println("calling test1.main()");
         test1.main();
     }
}

public class test1 {
     public static void main(String... args) {
         System.out.println("test1");
     }
}

Compiling test.jar and running test produces the following output:
C:\Users\Knute Johnson>java test
calling test1.main()
test1

Adding the .class files to a .jar and running it produces the same:

C:\Users\Knute Johnson>java -jar test.jar
calling test1.main()
test1

I have two questions, the first is how does the test1 class get loaded 
when test is run from the .jar?  When all the .class files are in the 
working directory they are in the CLASSPATH.  Are all of the classes in 
a .jar in the CLASSPATH too?

The second question is, what type is test.main()?  I want to be able to 
put it into a Map.

Thanks,

knute...

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


Thread

How does it know? Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2014-09-12 08:11 -0700
  Re: How does it know? Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2014-09-12 08:36 -0700
    Re: How does it know? Steven Simpson <ss@domain.invalid> - 2014-09-12 17:36 +0100
      Re: How does it know? Donkey Hottie <donkey@fredriksson.dy.fi> - 2014-09-12 21:40 +0300
        Re: How does it know? Joerg Meier <joergmmeier@arcor.de> - 2014-09-13 11:57 +0200
  Re: How does it know? Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2014-09-12 16:18 -0700
    Re: How does it know? Mike Amling <mamling@chaff.us> - 2014-09-14 08:52 -0500
      Re: How does it know? Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2014-09-14 07:48 -0700
  Re: How does it know? Roedy Green <see_website@mindprod.com.invalid> - 2014-09-12 18:11 -0700
    Re: How does it know? Joerg Meier <joergmmeier@arcor.de> - 2014-09-13 11:59 +0200
      Re: How does it know? Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2014-09-14 07:51 -0700
        Re: How does it know? Arne Vajhøj <arne@vajhoej.dk> - 2014-09-14 22:24 -0400
    Re: How does it know? Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2014-09-14 07:50 -0700
      Re: How does it know? Arne Vajhøj <arne@vajhoej.dk> - 2014-09-14 22:26 -0400
        Re: How does it know? Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2014-09-17 14:52 -0700
  Re: How does it know? Roedy Green <see_website@mindprod.com.invalid> - 2014-09-12 18:13 -0700
  Re: How does it know? Mike Amling <mamling@chaff.us> - 2014-09-14 08:29 -0500
    Re: How does it know? Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2014-09-14 07:53 -0700
      Re: How does it know? Roedy Green <see_website@mindprod.com.invalid> - 2014-09-17 00:40 -0700
        Re: How does it know? Joerg Meier <joergmmeier@arcor.de> - 2014-09-18 00:10 +0200

csiph-web