java.rst
changeset 2228 837f1337c59b
parent 2127 782577d2e7f0
child 2350 1141a548cbb6
equal deleted inserted replaced
2227:1e9323e7ec88 2228:837f1337c59b
     7    :local:
     7    :local:
     8 
     8 
     9 Class version.
     9 Class version.
    10 ==============
    10 ==============
    11 
    11 
    12   =========  ====== =====================
    12 
    13   major      minor  Java platform version
    13 =========  ====== =====================
    14   =========  ====== =====================
    14 major      minor  Java platform version
    15   45 0x27    3      1.0
    15 =========  ====== =====================
    16   45 0x27    3      1.1
    16 45 0x27    3      1.0
    17   46 0x28    0      1.2
    17 45 0x27    3      1.1
    18   47 0x29    0      1.3
    18 46 0x28    0      1.2
    19   48 0x30    0      1.4
    19 47 0x29    0      1.3
    20   49 0x31    0      5.0
    20 48 0x30    0      1.4
    21   50 0x32    0      6.0
    21 49 0x31    0      5.0
    22   51 0x33    0      7
    22 50 0x32    0      6.0
    23   52 0x34    0      8
    23 51 0x33    0      7
    24   =========  ====== =====================
    24 52 0x34    0      8
       
    25 =========  ====== =====================
    25 
    26 
    26 where ``minor`` and ``major`` are value of 6 and 8 bytes in .class file::
    27 where ``minor`` and ``major`` are value of 6 and 8 bytes in .class file::
    27 
    28 
    28   0xCA, 0xFE, 0xBA, 0xBE, 0x00, minor, 0x00, major
    29   0xCA, 0xFE, 0xBA, 0xBE, 0x00, minor, 0x00, major
    29 
    30 
    31 =================
    32 =================
    32 
    33 
    33 Public.
    34 Public.
    34 -------
    35 -------
    35 
    36 
    36  * Public class is visible in other packages.
    37 * Public class is visible in other packages.
    37  * Public field is visible everywhere (class must be public too).
    38 * Public field is visible everywhere (class must be public too).
    38 
    39 
    39 Private.
    40 Private.
    40 --------
    41 --------
    41 
    42 
    42  * Private variables or methods may be used only by an instance of the same
    43 * Private variables or methods may be used only by an instance of the same
    43    class that declares the variable or method
    44   class that declares the variable or method
    44  * A private feature may only be accessed by the class that owns the feature.
    45 * A private feature may only be accessed by the class that owns the feature.
    45 
    46 
    46 Protected.
    47 Protected.
    47 ----------
    48 ----------
    48 
    49 
    49  * Is available to all classes in the same package and also available to all
    50 * Is available to all classes in the same package and also available to all
    50    subclasses of the class that owns the protected feature.
    51   subclasses of the class that owns the protected feature.
    51  * This access is provided even to subclasses that reside in a different
    52 * This access is provided even to subclasses that reside in a different
    52    package from the class that owns the protected feature.
    53   package from the class that owns the protected feature.
    53 
    54 
    54 default.
    55 default.
    55 --------
    56 --------
    56 
    57 
    57 What you get by default ie, without any access modifier.
    58 What you get by default ie, without any access modifier.
    58 
    59 
    59  * It means that it is visible to all within a particular package.
    60 * It means that it is visible to all within a particular package.
    60 
    61 
    61 static.
    62 static.
    62 -------
    63 -------
    63 
    64 
    64  * Static means one per class, not one for each object no matter how many
    65 * Static means one per class, not one for each object no matter how many
    65    instance of a class might exist. This means that you can use them without
    66   instance of a class might exist. This means that you can use them without
    66    creating an instance of a class.
    67   creating an instance of a class.
    67  * Static methods are implicitly final, because overriding is done based on
    68 * Static methods are implicitly final, because overriding is done based on
    68    the type of the object, and static methods are attached to a class, not an
    69   the type of the object, and static methods are attached to a class, not an
    69    object.
    70   object.
    70  * A static method in a superclass can be shadowed by another static method in
    71 * A static method in a superclass can be shadowed by another static method in
    71    a subclass, as long as the original method was not declared final.
    72   a subclass, as long as the original method was not declared final.
    72  * You can't override a static method with a nonstatic method.
    73 * You can't override a static method with a nonstatic method.
    73 
    74 
    74 final.
    75 final.
    75 ------
    76 ------
    76 
    77 
    77  * A final class can't be extended ie., final class may not be subclassed.
    78 * A final class can't be extended ie., final class may not be subclassed.
    78  * A final method can't be overridden when its class is inherited.
    79 * A final method can't be overridden when its class is inherited.
    79  * You can't change value of a final variable.
    80 * You can't change value of a final variable.
    80 
    81 
    81 Exceptions.
    82 Exceptions.
    82 ===========
    83 ===========
    83 
    84 
    84 A checked exception is some subclass of Exception (or Exception itself),
    85 A checked exception is some subclass of Exception (or Exception itself),
   132 anonymous classes have no name, you cannot provide a constructor.
   133 anonymous classes have no name, you cannot provide a constructor.
   133 
   134 
   134 64-bit problem.
   135 64-bit problem.
   135 ===============
   136 ===============
   136 
   137 
   137   http://www.java.com/en/download/faq/java_win64bit.xml
   138 http://www.java.com/en/download/faq/java_win64bit.xml
   138                 Which version of Java should I download for my 64-bit Windows
   139   Which version of Java should I download for my 64-bit Windows
   139                 operating system?
   140   operating system?
   140   http://java.sun.com/javase/6/webnotes/install/system-configurations.html
   141 http://java.sun.com/javase/6/webnotes/install/system-configurations.html
   141                 Java SE 6 Release Notes Supported System Configurations
   142   Java SE 6 Release Notes Supported System Configurations
   142 
   143 
   143 Java performance.
   144 Java performance.
   144 =================
   145 =================
   145 
   146 
   146   http://java.sun.com/performance/reference/whitepapers/5.0_performance.html
   147 http://java.sun.com/performance/reference/whitepapers/5.0_performance.html
   147   http://java.sun.com/performance/reference/whitepapers/6_performance.html
   148 http://java.sun.com/performance/reference/whitepapers/6_performance.html
   148 
   149 
   149 Creating jar.
   150 Creating jar.
   150 =============
   151 =============
   151 ::
   152 ::
   152 
   153 
   253   for instant access to methods and fields.
   254   for instant access to methods and fields.
   254 
   255 
   255 Find jar by class.
   256 Find jar by class.
   256 ==================
   257 ==================
   257 
   258 
   258   http://mvnrepository.com/search.html?query=PKG
   259 * http://mvnrepository.com/search.html?query=PKG
   259   http://www.jarfinder.com
   260 * http://www.jarfinder.com
   260 
   261 
   261 Set default Java in Debian.
   262 Set default Java in Debian.
   262 ===========================
   263 ===========================
   263 ::
   264 ::
   264 
   265 
   311 
   312 
   312   <web-app xmlns="http://java.sun.com/xml/ns/javaee" version="3.0">
   313   <web-app xmlns="http://java.sun.com/xml/ns/javaee" version="3.0">
   313 
   314 
   314 See:
   315 See:
   315 
   316 
   316   http://en.wikipedia.org/wiki/Java_EE_version_history
   317 http://en.wikipedia.org/wiki/Java_EE_version_history
   317     Java EE version history.
   318   Java EE version history.
   318   http://jcp.org/aboutJava/communityprocess/final/jsr315/index.html
   319 http://jcp.org/aboutJava/communityprocess/final/jsr315/index.html
   319     Servlet 3.0 Specification
   320   Servlet 3.0 Specification
   320   http://jcp.org/aboutJava/communityprocess/mrel/jsr154/index.html
   321 http://jcp.org/aboutJava/communityprocess/mrel/jsr154/index.html
   321     Servlet 2.5 Specification
   322   Servlet 2.5 Specification
   322   http://www.mularien.com/blog/2008/04/24/how-to-reference-and-use-jstl-in-your-web-application/
   323 http://www.mularien.com/blog/2008/04/24/how-to-reference-and-use-jstl-in-your-web-application/
   323     How to Reference and Use JSTL in your Web Application
   324   How to Reference and Use JSTL in your Web Application
   324 
   325 
   325 Java interactive shell.
   326 Java interactive shell.
   326 =======================
   327 =======================
   327 
   328 
   328 Just use Groovy. ``bsh`` is older alternative without code completion.
   329 Just use Groovy. ``bsh`` is older alternative without code completion.