WORKING WITH NETBEANS IDE

nutmegactΛογισμικό & κατασκευή λογ/κού

10 Νοε 2012 (πριν από 4 χρόνια και 7 μήνες)

234 εμφανίσεις

WORKING WITH NETBEANS IDE


STEP 1
:
how to create a new java
project



Go
to the File menu


Select
New Project


Choose
Categories of project as Java


Choose Project as Java Application


Give a Name to the Project


Give a Location to the Project


If you did not give name and location to the Project

then
default Name and
Location is selected.


Default Location is where the IDE is installed


Uncheck the “Create Main Class” Check Box









STEP 2:

How to create a new Java file for an existing java project



Right Click on Project Name


Click on New


Select Java class


Give a Name to the File


Location of the file is automatically selected as the location of the project


STEP 2(a):

How to create java bean class



Create a java class (assume “Hello.java”) file by using step2.


When you open this file you will find the class “public class Hello { }” is
already present there.


Modify this class as “public class Hello implements
Serializable

{}”.


Inside the curly braces write the member of the class (assume “String
greeting”).


Now we have to write pair of getter/setter methods for the member’s of
the class.


We can automatically generate pair of getter/setter method by following
method


C
licking on the “
Refactor

Menu”.



Select
“Encapsulate Field”.



Click
on “Select all” Button.



Click
on “
Refactor
” Button
.


We can also automatically generate the packages required to import by
using the following method


Right click on code window.


Click on “Fix Import”.

















STEP 2(b):

How to create java dependency injection class



Create a java class (assume “HelloTest.java”) file by using step2.


Note that java dependency injection class has main method.


Here we have to give the name of xml file where we are going to stored
our data


(
ApplicationContext context = new ClassPathXmlApplicationContext (new
String []{"
xml file name
"});).



Here we use an object (assume “he”) of our java bean class (assume
“Hello”) and by using this object we call the getter method (assume
“GetGreeting”) of java bean class.



Hello

he

= (
Hello
) context.getBean("
he
");



System.out.println(he.get
Greeting
());


We import the packages required by using “fix Import “.





STEP 3:

How to create a new Xml file for an existing java project



Right
Click on Project Name


Click on New


Select XML Document


Give a Name to the XML Document


Location of the file is automatically selected as the location of the project


Select Document type as well
-
formed document





STEP 3 (a):

How to write code for XML File



Write xml “Declaration statements “ as shown below



<? xml version="1.0" encoding="UTF
-
8"?>



<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema
-
instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring
-
beans
-
2.5.xsd">



Write
” id”

as the
” object of our java bean class” (
assume “he”) and
“class”

as
“class name of our java bean class”

(assume “Hello”) as shown
below



<bean id="he" class="Hello">



Write
“name”

as
“name of the member of our java bean class”

and

value”

as
“what we want to display on output”
as shown below



<property name="greeting" value="hello neatbeans"></property>


All the start tag must have end tag



<property> start tag must be closed by </property>end tag



< bean> start tag must be closed by</bean>end tag



<beans> start tag must be closed by </beans>end tag



STEP 4
:
How to add Spring
-
2.5 /commons
-
logging
-
1.1 jar files



Right click on the project name


Click on Properties


Click on Libraries


Click on Add/Folder button


Select Spring
-
2.5 /commons
-
logging
-
1.1


Click on open button


Click on ok button