Notepad++ - Tutorial Compile and Run Java Program
Notepad++ - Tutorial Compile and Run Java Program
Notepad++ - Tutorial Compile and Run Java Program
The
COMPSCI
101
Text
Editor
for
Windows
The
text
editor
that
we
will
be
using
in
the
Computer
Science
labs
for
creating
our
Java
programs
is
called
Notepad++
and
is
http://notepad-‐plus.sourceforge.net
freely
available
for
the
Windows
operating
system.
If
you
plan
to
do
work
outside
of
the
labs,
perhaps
at
home,
you
may
like
to
use
the
same
software
that
we
have
available
in
the
labs.
This
document
describes
how
to
install
and
configure
Notepad++
using
the
same
settings
available
in
the
labs.
What
is
a
text
editor?
A
text
editor
is
a
program
that
enables
you
to
write
plain
text
files
(a
text
file
is
a
file
that
consists
of
lines
of
text
comprised
mainly
of
the
characters
that
you
can
type
on
a
keyboard).
A
common
extension
for
text
files
is
.txt,
although
the
Java
source
files
that
we
are
creating
in
this
course
are
also
examples
of
text
files
and
use
the
extension
.java.
There
are
many
text
editors
that
are
freely
available
for
you
to
use.
For
example,
Windows
provides
a
very
simple
text
editor
called
Notepad
(that
you
can
find
under
the
Accessories
menu).
However,
this
is
not
a
very
good
editor
for
writing
source
code
because
it
doesn’t
support
useful
features
such
as
syntax-‐colouring,
auto-‐indentation
and
brace
highlighting.
Notepad++
is
a
freely
available
text
editor
for
Windows,
and
is
the
editor
we
will
be
using
in
the
labs
to
write
our
Java
source
code.
Install
Java
(JDK)
Unzip
the
file
and
you
should
see
the
following
folder
on
your
desktop:
Right-‐click
the
installer.exe
file
and
and
select
"run
as
administrator".
Notepad++
will
now
be
installed
on
your
computer.
To
check
that
you
have
installed
Notepad++
correctly,
run
the
application
(a
link
should
appear
on
your
desktop)
and
you
should
see
an
editor
window
like
the
following
appear:
Configuring
Notepad++
In
the
labs,
certain
commands
and
short-‐cut
keys
have
been
defined
to
make
it
easier
for
you
to
compile
and
run
your
Java
applications.
This
section
will
describe
how
to
configure
Notepad++
so
that
the
same
commands
and
short-‐cut
keys
are
available
to
you.
Display
Font
If
you
would
like
to
set
the
display
font
to
be
identical
to
the
settings
used
in
the
labs,
go
to:
Settings
>
Style
Configurator...
Set
Font
to
Courier,
and
Font
size
to
12
for
Language:
Global
Styles
and
Style:
Global
override
NppExec
Plugin
Open
the
Plugins
menu.
You
will
need
an
option
called
NppExec
in
this
menu
and
it
may
not
be
present
by
default
(as
in
the
example
screenshot
below):
Notepad++
configuration
instructions
Page
3
If
the
NppExec
plugin
is
not
present,
you
can
enable
it
by
going
to
Plugin
Manager
and
selecting
Show
Plugin
Manager:
From
here,
find
the
NppExec
plugin,
and
select
it
–
then
click
Install:
You
will
be
prompted
to
restart
Notepad++.
Click
Yes
and
wait
for
Notepad++
to
restart.
You
should
now
see
NppExec
appearing
on
the
Plugins
menu:
Short-‐cut
keys
Define
functions
and
corresponding
short-‐cut
keys
for
compiling
and
running
Java
programs:
1.
Go
to
Plugins
>
NppExec
>
Execute...
2.
Choose
“Cancel”
if
a
Save
File…
dialog
box
appears
3.
Enter
the
following
command:
cd
“$(CURRENT_DIRECTORY)”
javac
$(FILE_NAME)
as
shown
below:
4.
Save
two
more
commands:
One
called
“Run”:
cd
$(CURRENT_DIRECTORY)
java
$(NAME_PART)
Notepad++
configuration
instructions
Page
6
and
another
called
“Compile
and
Run”
cd
$(CURRENT_DIRECTORY)
javac
$(FILE_NAME)
java
$(NAME_PART)
5.
Define
the
scripts
for
the
short-‐cut
keys:
Go
to
NppExec
Advance
Options
and
enable
"Place
to
the
Macros
submenu".
You
should
see
the
script
added
in
the
“Menu
items”
box
as
shown
above.
Repeat
this
process
for
the
other
two
scripts,
be
careful
to
type
the
names
“Run”
and
“Compile
and
Run”
in
the
“Item
name:”
box
before
hitting
the
Add/Modify
button.
The
screenshot
below
shows
what
this
should
look
like
when
you
have
added
all
three
scripts:
Notepad++
configuration
instructions
Page
8
Select
OK
–
you
will
be
shown
a
dialog
box
indicating
the
Notepad++
needs
to
restart.
Select
OK,
and
close
Notepad++,
then
open
it
again.
and
select
the
“Plugin
commands”
tab.
Scroll
down
to
find
the
scripts
you
defined:
Double-‐click
the
“Compile”
script
name
to
bring
up
the
“Shortcut”
box.
In
this
box,
you
can
enter
the
desired
short
cut
for
the
“Compile”
script.
Enter
CTRL+1
as
shown
below:
Notepad++
configuration
instructions
Page
10
Repeat
this
for
the
other
two
scripts
so
that
you
have
defined:
Compile:
Ctrl
+
1
Run:
Ctrl
+
2
Compile
and
Run:
Ctrl
+
3
and
then
click
the
“Close”
button
Output
Font
To
set
the
font
for
the
output
window,
go
to
Plugins
>
NppExec
>
Change
Console
Font,
and
set
to
Courier
font,
and
Font
size
to
12
To
test
that
the
Notepad++
has
been
configured
correctly,
enter
the
following
source
code
into
the
editor:
public class Test {
public static void main(String[] args) {
System.out.println("Hello world!");
}
}
and
save
the
file
in
some
location
on
your
disk:
You
should
now
be
able
to
use
the
short-‐cut
keys
(or
you
can
select
them
from
the
“Macro”
menu)
to
compile
and
run
your
program:
Notepad++
configuration
instructions
Page
12
You
should
see
the
console
pane
appear
with
output
from
the
compiler:
You
can
then
run
the
program:
and
you
should
see
the
output
appear
in
the
console
window: