Download IDE (Integrated Development Environment) rīks NetBeans

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
1
IDE (Integrated
NetBeans
Development
Environment)
rīks
2
IDE rīki NetBeans projektu tipi
Java Application. Creates a new Java SE application in a standard IDE project. You can also
generate a main class in the project. Standard projects use an IDE-generated Ant build script to
build, run, and debug your project.
Java Desktop Application. Creates a skeleton of a desktop application based on the Swing
Application Framework (JSR 296). This template provides basic application infrastructure such as a
menu bar, persisting of window state, and status bar. With this template, you can also generate code
to create a GUI interface for a database table.
Java Class Library. Creates a new Java SE library in a standard IDE project. A Java SE library
does not contain a main class. Standard projects use an IDE-generated Ant build script to build,
run, and debug your project.
Maven is a framework that provides help with managing the project lifecycle, including building
and managing dependencies. Maven projects follow a set of standards that are described with a
Project Object Model (POM) to ensure consistency between projects.
When using Maven as the build infrastructure for Java projects, Maven uses conventions and
patterns in order to provide a uniform build system. All Maven projects use a shared set of plugins
that are retrieved from the Maven repository and Maven executes a defined series of tasks as part of
the lifecycle when building the project. Unlike Ant, you do not need to explicitly specify all the
tasks required for building a project.
3
Java projektu veidošana ar IDE rīku NetBeans
Projekta izveide un
konfigurēšana
Projekta
(savākšana)
1. Create the project using the best template for your programming
needs.
2. Configure the classpath for the project. You can add a JAR file, a
library, or an IDE project to the classpath.
1. Choose Run > Clean and Build Main Project or right-click any
izvietošana project and choose Clean and Build Project.
Projekta izpilde
Projekta atkļūdošana
1. If necessary, set the main class and arguments for the project.
2. Choose Run > Run Main Project or right-click any project and
choose Run Project.
1. Set breakpoints or watches in your code.
2. Choose Run > Debug Main Project or right-click any project and
choose Debug Project. You can also attach the debugger to a
running process.
3. Step through the program execution.
4. Choose Run > Finish Debugging Session when you are finished
debugging.
4
Java projektu veidnes (šabloni)
For each type of Java application, the IDE provides two types of project templates:
1. Standard templates. Templates in which the IDE controls all source and classpath settings,
compilation, running, and debugging.
2. Free-form templates. Templates in which your own Ant script controls all classpath settings,
compilation, running, and debugging.
Standard Project Templates
With standard project templates, the IDE controls all aspects of how your application is built, run,
and debugged. You set a project's source folder, classpath, and other project settings when creating
the project and in the Project Properties dialog box. The IDE generates an Ant build script in which
all of your settings are stored.
The IDE comes with the following standard templates:
1. Standard Java Applicatons. Java Application, Java Desktop Application, Java Class Library,
Java Project with Existing Sources
2. Web Applications. Web Application, Web Application with Existing Sources
3. Enterprise Applications. Enterprise Application, Enterprise Application with Existing Sources
4. EJB Modules. EJB Module, EJB Module with Existing Sources
5. Enterprise Application Clients. Enterprise Application Client, Enterprise Application Client
with Existing Sources
6. Enterprise Packaged Archives. Packaged Archive
7. NetBeans Modules. Module Project, Module Suite Project, Library Wrapper Module Project
Depending on what modules you have installed, your IDE may contain additional templates.
Consult the help for your additional modules for more information.
Free-Form Project Templates
With free-form project templates, the IDE relies on your existing Ant script for instructions on how
to compile, run, and debug your applications. The settings you configure in the New Project wizard
when creating a project as well as in the Project Properties dialog box are used to tell the IDE how
your Ant script manages your source code and must be consistent with the settings in your Ant
script.
For example, all classpath elements are handled by your Ant script. When you declare the classpath
for a free-form project, you are only telling the IDE which classes to make available for code
completion and refactoring. These settings do not affect the actual classpath used when compiling
or running your source code.
Free-form projects can contain as many source folders as your Ant script is configured to handle. If
your Ant script does not contain targets for all IDE actions, like debugging and running your
project, you can easily write Ant targets for these actions.
The standard distribution of the IDE contains the following free-form project templates:
1. Java Free-Form Project. A free-form Java project.
2. Web Free-Form Project. A free-form project containing a web application.
5
About Standard Projects
The IDE contains a set of standard project templates for Java SE applications and web applications.
Standard Java projects offer the highest integration with the IDE's support of certain technologies.
The standard distribution of the IDE contains the following standard templates:
1. For Java SE applications:
1) Java Application. An empty Java SE project with a main class.
2) Java Desktop Application. A skeleton application that is based on the Swing Application
Framework and contains a menu bar, status bar, and About box. This template also provides basic
application infrastructure such as persisting of window state and resource management. With this
template, you can also generate code to create a GUI interface for a database table.
3) Java Class Libary. An empty Java class library with no main class.
4) Java Project with Existing Sources. A Java SE project with existing sources.
2. For web applications:
1) Web Application. An empty web application.
2) Web Project with Existing Sources. A web application with existing sources.
3. For EJB modules:
1) EJB Module. An empty EJB module.
2) EJB Module with Existing Sources. An EJB module with existing sources.
4. For enterprise applications:
1) Enterprise Application. An empty enterprise application.
2) Enterprise Application with Existing Sources. An enterprise application with existing sources
that conform to the Sun Java BluePrints Guidelines.
5. For NetBeans modules:
1) Module. An empty module with a layer.xml file and a Bundle.properties file. You use a module
to implement the logic that integrates the library wrappers into the platform and provides a user
interface for receiving user input.
2) Library Wrapper. A library wrapped in a module project and a Bundle.properties file. You use
a library wrapper to put a library JAR file on a module's classpath and export some or all of the JAR
file's packages from the module as public packages.
3) Module Suite. An empty module suite. You use a module suite to group and deploy a set of
interdependent modules and library wrappers.
Depending on what modules you have installed, your IDE may contain additional templates.
Consult the help for your additional modules for more information.
6
Source Folders
In standard projects, you can have multiple source folders and multiple JUnit test folders for each
Java SE, web, and EJB project. A single source folder cannot, however, be added to more than one
project. If you need a source folder to be part of several projects, you should create a separate
project for the source folder and add it to the classpath of each of your projects.
Project Settings
When you create a project from a standard project template, the IDE generates an Ant script that
controls all aspects of program compilation, execution, and debugging.
You can set basic project settings in the Project Properties dialog box by right-clicking a project
node in the Projects window and choosing Properties. All changes are immediately registered in the
project's Ant script. You can also set more complex options by editing the project's Ant script and
properties file directly.
The Project Folder
Each standard project has a project folder where the IDE stores the Ant script, project metadata, and
output folders. In projects with existing sources, you can place the project source directories in the
same location as the project folder or in a separate location. In empty projects, the source root is
always in the same location as the project directory.
The following table lists the contents of a project folder:
Item
Description
build.xml
The build script called by the IDE. This build script only contains an import
statement that imports targets from nbproject/build-impl.xml. Use the build.xml
to override targets from build-impl.xml or to create new targets.
nbproject
The directory that contains the project Ant script and other metadata.This
directory contains:

build-impl.xml. The IDE-generated Ant script. You should never edit
build-impl.xml directly — always override its targets in build.xml.

project.properties. Ant properties used by the IDE to configure the Ant
script. Although you can edit this file manually, you generally do not need to, as
it is automatically updated by the IDE when you configure the project's
properties.

project.xml and genfiles.properties. IDE-generated metadata files.
Although you can edit project.xml manually, for standard projects you generally
do not need to. You should never edit genfiles.properties.
nbproject/private The directory that holds properties that are defined for you only. If you are
sharing the project over VCS, any properties you define in private.properties are
not checked in with other project metadata and are applied only to your
installation of the IDE.
build
The output directory for compiled classes.
dist
The output directory of packaged build outputs (JAR files and WAR files).
Standard Java projects produce one build output per project. The dist directory
also contains generated Javadoc documentation.
7
NetBeans serveri
A server is a computer that serves up applications. Any computer can be turned into a server if you
install server software and connect the computer to the Internet. A number of servers are supported
by the IDE.
Before you can deploy an enterprise application, web application, JSP, servlet, or EJB module, the
server to which you are going to deploy needs to be registered with the IDE. When a server is
registered with the IDE, its libraries are available for production, or deployment, or both. Servers
that are installed during the IDE installation process are automatically registered in the IDE. You
must register all other servers yourself.
Only once you have registered a Java EE application server can you begin developing enterprise
applications.
When a server is registered with the IDE, you can see its node in the Services window under the
Servers node. When you create a project in the New Project wizard, you can select the server to
which you want to deploy your application. After you create the application, you can change the
server by right-clicking the project, choosing Properties, clicking Run, and selecting a different
server.
A Java EE application server, also known as a Java EE container, is any server that is fully
compliant with the J2EE 1.4 platform. Unlike a regular web server, an application server can:
1) run full enterprise applications;
2) run enterprise bean modules;
3) run web services;
4) use Container-Managed Persistence (CMP) entity beans to handle communication with a
database.
The IDE supports the following application servers:
1. Sun Java System Application Server/GlassFish. The IDE provides the fullest support for the
Sun Java System Application Server. You can stop and start the server, deploy applications to it,
and view the deployed modules directly in the Services window. There is a visual editor for serverspecific deployment descriptors and the IDE updates the descriptors automatically as you write your
code. The IDE also automatically configures server resources like connection pools and JavaMail
resources for this application server.
2. JBoss Application Server.
3. BEA WebLogic Application Server.
4. IBM WebSphere Application Server.
The IDE provides basic support for these application servers. You can start, stop, and debug the
servers and deploy applications to them.
Tomcat Web Server and its libraries are used for the following activities:
1) deploying web applications, JSP pages, and servlets;
2) deploying web services and web service clients that use JSR-101 stubs;
3) you can also configure the Tomcat web server to run web services.
The Tomcat Web Server is not a J2EE 1.4 container. Therefore, you cannot deploy a web service
client that uses JSR-109 stubs to this server. When you create the web service client, make sure that
you select IDE-generated static stub in the Client Type drop-down.
8
Java projekta ar divām klasēm Main un Darbinieks
izveidošana un izpilde
1. Jauna projekta veidošana.
2. Projekta tipa izvēle.
3. Projekta nosaukuma un glabāšanas vietas ievade.
4. Iegūtais rezultāts (projekts ar tā komponentēm).
9
5. Jaunas klases Darbinieks izveidošana.
6. Klases Darbinieks programmas ievade.
package javalietoj1;
public class Darbinieks {
// klases atribūti
private String Uzvards;
private double
Alga;
private int DzimGads;
// konstruktora funkcija
public Darbinieks (String uzv, double alg, int gads) {
Uzvards
= uzv;
Alga
= alg;
DzimGads = gads; }
// metodes
public
String
getUzvards() { return Uzvards; }
public
double
getAlga() { return Alga; }
public
int getDzimGads() { return DzimGads; }
public void
Algas_maina (double procents) {
double pieaugums = Alga * procents /100;
Alga += pieaugums; } }
10
7. Klases Darbinieks struktūra Navigatora logā
8. Klases Main programmas kods.
package javalietoj1;
public class Main {
public static void main (String [ ] args) {
Darbinieks [ ] darbinieki = new Darbinieks [3];
darbinieki [0] = new Darbinieks ("Koks", 400.50, 1980);
darbinieki [1] = new Darbinieks ("Celms", 500.50, 1985);
darbinieki [2] = new Darbinieks ("Sakne", 550.50, 1970);
for (Darbinieks d : darbinieki)
System.out.println("uzvards= "+ d.getUzvards() + ", alga= " + d.getAlga() );
}}
9. Izveidotās klases.
10. Klases Darbinieks kompilācija: Run  Compile „Darbinieks.java”
11. Klases Main kompilācija: Run  Compile „Main.java”
12. Projekta izpilde: Run  Run Main project
11
Java projekta ar klasi Darbinieks un pārbaudes klasi
DarbinieksTests izveide un izpilde
public class
Klases_nosaukums {
public class Darbinieks {
klases_atribūts_1
// klases atribūti
klases_atribūts_2
private String
UZVARDS;
…
private double
ALGA;
konstruktors_1
private int
DZIM_GADS;
konstruktors_2
// konstruktora funkcija
…
public Darbinieks (String uzv, double alg, int gads) {
metode_1
UZVARDS = uzv;
metode_2
ALGA
= alg;
… }
DZIM_GADS
= gads; }
// metodes
public
String
getUzvards() { return uzvards; }
public
double
getAlga() { return alga; }
public
int
getDzim_gads() { return dzim_gads; }
public void
Algas_maina (double procents) {
double pieaugums = ALGA * procents /100;
ALGA += pieaugums; } }
public class DarbinieksTests {
public static void main (String [ ] args) {
Darbinieks [ ] darbinieki = new Darbinieks [3];
darbinieki [0] = new Darbinieks ("Koks", 400.50, 1980);
darbinieki [1] = new Darbinieks ("Celms", 500.50, 1985);
darbinieki [2] = new Darbinieks ("Sakne", 550.50, 1970);
for (Darbinieks d : darbinieki)
System.out.println("uzvards= "+ d.getUzvards() + ", alga= " + d.getAlga() );
}}
uzvards= Koks, alga= 400.5
uzvards= Celms, alga= 500.5
uzvards= Sakne, alga= 550.5
Process exited with exit code 0.
12
1. Jauna projekta veidošana (New Project)
2. Java lietojuma veidošanas izvēle
3. Projekta nosaukuma un glabāšanas vietas ievade
4. Jaunas klases Darbinieks izveidošana
13
5. Klases Darbinieks un programmu paketes Pakete_4 nosaukumu ievade
6. Klases Darbinieks definējums
7. Klases Darbinieks kompilācija
14
8. Jaunas klases DarbinieksTests izveidošana
9. Klases DarbinieksTests definējums
10. Klases DarbinieksTests kompilācija
11.Projekta JavaLietojums4 sastāvdaļas
12. DarbinieksTests klases izpilde
15