Title
Question
Java-Business-Application Overview-of-Library-Management-System 00-01 min 0-10 sec
Answers:
In the IDE, choose Tools > Java Platforms from the main menu.
</li><li style="box-sizing: inherit; margin: 0px; padding: 0px; font-size: inherit;">Click Add Platform in the Java Platform Manager dialog.
</li><li style="box-sizing: inherit; margin: 0px; padding: 0px; font-size: inherit;">In the Add Java Platform dialog, select Java Standard Edition and click Next.
</li><li style="box-sizing: inherit; margin: 0px; padding: 0px; font-size: inherit;">Specify the directory that contains the JDK and click Next.
</li></ol>Verify that the default locations of the Platform Sources zip file and API documentation are valid. Click Finish to close the Add Java Platform dialog box. JDK 8 is registered as a platform in the IDE.
</li></ol>Ensure JDK 1.8 is chosen in the Platforms list and click Close.
</li></ol>After you registered JDK 8 in the IDE, your project needs to be configured to use JDK 8 for compilation, running, and debugging.
We will start by creating a new Java SE project with the Anagram game example which is shipped with NetBeans IDE.
In the IDE, choose File > New Project.
</li><li style="box-sizing: inherit; margin: 0px; padding: 0px; font-size: inherit;">In the New Project wizard, expand the Samples category and select Java.
</li><li style="box-sizing: inherit; margin: 0px; padding: 0px; font-size: inherit;">Choose Anagram Game in the Projects list. Then click Next.
</li><li style="box-sizing: inherit; margin: 0px; padding: 0px; font-size: inherit;">In the Name and Location panel, leave the default values for the Project Name and Project Location fields.
</li><li style="box-sizing: inherit; margin: 0px; padding: 0px; font-size: inherit;">Click Finish. The IDE creates and opens the Java SE project in the Projects window.
</li></ol>To configure your project to use JDK 8:
Right-click the AnagramGame project in the Projects window and select Properties from the context menu.
</li><li style="box-sizing: inherit; margin: 0px; padding: 0px; font-size: inherit;">In the Project Properties dialog box, choose the Libraries category and set JDK 1.8 as the Java Platform.
</li></ol>Select the Sources category and set Source/Binary Format to JDK 8.
</li></ol>Click OK to save the changes. Your project is set to recognize new JDK 8 language features.
</li></ol>Java SE 8 introduces <a href="http://openjdk.java.net/jeps/161" style="box-sizing: inherit; line-height: inherit; color: rgb(165, 7, 62); cursor: pointer;">subset profiles of the Java SE platform specification</a> that can be used to deploy and run applications that do not require the entire platform.
Three profiles that have been defined so far are named compact1, compact2, and compact3. Each profile specifies a particular set of Java API packages and contains all of the APIs in profiles smaller than itself: compact1 is a subset of compact2, which is a subset of compact3, which in its turn is a subset of the full JRE. The table below lists packages that are comprised in each profile.
* java.lang * java.io * java.nio * java.text * java.math * java.net * javax.net * java.util * java.util.logging * java.security * javax.crypto * javax.security
</td><td class="tableblock halign-left valign-top" style="box-sizing: inherit; margin: 0px; padding: 0.5rem 0.625rem 0.625rem; vertical-align: top;">compact1 plus the following:
* java.sql * javax.sql * javax.xml * org.w3c.dom * org.xml.sax * java.rmi * javax.rmi * javax.transaction
</td><td class="tableblock halign-left valign-top" style="box-sizing: inherit; margin: 0px; padding: 0.5rem 0.625rem 0.625rem; vertical-align: top;">compact2 plus the following:
* java.lang.management * javax.management * javax.naming * javax.sql.rowset * javax.security.auth.kerberos * org.ietf.jgss * javax.script * javax.xml.crypto * java.util.prefs * javax.security.sasl * javax.security.acl * java.lang.instrument * javax.annotation.processing * javax.lang.model * javax.lang.model.element * javax.lang.model.type * javax.lang.model.util * javax.tools
</td><td class="tableblock halign-left valign-top" style="box-sizing: inherit; margin: 0px; padding: 0.5rem 0.625rem 0.625rem; vertical-align: top;">compact3 plus the following:
* corba * awt * swing
</td></tr></tbody></table>The IDE allows you to switch between the profiles and the full JRE when needed.
To set a project profile for a Java SE Project:
Right-cick a project and choose Properties from the context menu.
</li><li style="box-sizing: inherit; margin: 0px; padding: 0px; font-size: inherit;">In the Project Properties dialog box, select the Sources category.
</li><li style="box-sizing: inherit; margin: 0px; padding: 0px; font-size: inherit;">Use the Profile drop-down list to specify the JDK 8 profile that your application will support.
</li></ol>Click OK.
</li></ol>To see how the IDE checks whether classes used in your project belong to the specified profile, select Compact1 as a profile for the AnagramGame project and click OK. The IDE displays errors to notify that the AnagramGame project is not compliant with the compact1 profile.
You can go back and set the AnagramGame project’s profile to Full JRE which is supported by the Anagrams application.
<a href="http://openjdk.java.net/projects/lambda/" style="box-sizing: inherit; line-height: inherit; color: rgb(165, 7, 62); cursor: pointer;">Lambda expressions</a> address the bulkiness of anonymous inner classes by expressing the machinery of anonymous inner classes more compactly.
The general syntax of a lambda expression consists of a set of parameters, an arrow token, and a function body (either a single expression or a statement block):
NetBeans IDE detects pre-lambda expressions and displays the hints in the Editor proposing to turn such constructs into lambda expressions.
For example, the AnagramGame project features a pre-lambda construct in the <code style="box-sizing: inherit; font-family: Consolas, Menlo, "Liberation Mono", Courier, monospace; font-size: 0.75rem; line-height: 1.4; margin-top: 0px; margin-bottom: 0.5rem; padding: 0.125rem 0.312rem 0.062rem; border: 0px; background-color: transparent; color: rgb(10, 10, 10);">Anagrams.java</code> file as shown in the screenshot below.
After you click the light bulb in the margin or press Alt-Enter, the IDE shows the Use Lambda hint with a set of options available:
If the Use Lambda hint is selected, the IDE converts the anonymous inner class into a lambda expression.
If you choose the Run Inspect on option, the IDE displays the Inspect dialog box that allows to run a single Convert to Lambda inspection on the specified file.
Login to add comment