How to run Java program with tester library using ...

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

15 Αυγ 2012 (πριν από 5 χρόνια και 4 μέρες)

391 εμφανίσεις

How to run Java program with tester library using
NetBeans

IDE.




Download and install
NetBeans
.



Decide where you will keep your work and define two folders/directories, one
for the project workspace and one for the libraries you will use. We will name
them
NetBeansWorkspace

and
NetBeansJars.



Start
NetBeans
. Your workspace should look like this:






I
n
File

menu select
New

then
Java
then
Java Application
:





Choose the project name (e.g. Project1), select to
Next.



A window will ask you to choose the location for your project. Select the
NetBeansWorkspace folder
.





Name the project

Project1
and
Browse

to select the project location.






Check the button
Use Dedicated Folder for Storing Libraries

then
Browse
. It will
then ask you for the location of the libraries you want to use. Select
NetBeansJars
. (Our example shows
EclipseJars



as we share these with the
Eclipse projects.)






Check
Set as Main Project
, and
Finish
.



In the Projects tab hit the triangle next to
Project1
, then again next to
Source
Packages
.




In the
File

menu choose
New File
. In the left pane select
Java
, then se
lect
Empty
Java File
.





Choose the name for the class
---

Shapes

and
Finish
.




Copy and paste the file
Shapes.java

into the center pane that now has a label
Shapes.java
. You should see the following in the center pane:







Save the file, by selecting
Save

in the
File

menu, or by using the
Save

button in the
toolbar.

You can edit the file as you wish


maybe adding a comment about the
author, or today’s date.



However, your program still shows a number of errors. You need to tell the
Project

where to fin
d the
tester

library.
In
File

menu select
Project Properties
(Project1)
.



In the left pane select
Libraries
.




O
n the
right select

Add JAR
/Folder

in the window that appears select
tester.jar
.






If you want to use the World libraries, select also the thre
e additional jars:
draw.jar
,
geometry.jar
, and
colors.jar
.



When you get back to the Project Properties window, select
Run

in the left pane.




Type in the name of the Main class as
tester.Main
, then hit
Apply

and
Run
.



You will see the
results. They indicate some errors to be fixed. At any time, if you
double
-
click inside of one of the windows (Java file, Output), it will appear as a
full size window. If you double
-
click again, it will return back to its original
position and size within

the NetBeans workspace.






In the inexact comparisons both pieces of data should be of the type
double
. Fix
it and run again. To run again just hit the green
Run

button in the toolbar, as long
as your Java program file is currently showing in the main pa
ne. You should see
success
.