Anda di halaman 1dari 7

5/23/2014 A Beginning Programmer' s Guide to Java: applet

http://beginwithjava.blogspot.ca/search/label/applet 1/7
S H A R E
Share this on Facebook
Tweet this
View stats
(NEW) Appoi ntment gadget >>
T H UR S D A Y , O C T O B E R 20, 2011
Mobile Java
One of the nice things about Java is that is supported on more than desktop
platforms, and has been for a long time. This means there is not only a large
library of existing software, but also well-tuned development systems to use
with mobile platforms.
By "mobile platform", I'm referring to smartphones and tablets. There are other
mobile platforms, but these are the most common ones. Netbooks may also run
a "mobile" operating system, or they may run a normal desktop OS. Those that
run a normal desktop OS will run normal Java SE applications. Java SE is "Java,
Standard Edition", the version that typically runs on a desktop or laptop
computer.
Java ME is Java, Mobile Edition. It runs on most smartphones, and many tablets.
It is very similar to the Java SE version covered in most of my articles. In fact, it
is possible to write many applications using a subset of Java that will run
without change under both Java SE and Java ME.
But normally a Java ME application will use user interface objects and interfaces
that are specific to Java ME. In many ways these are more sophisticated than
the ones for Java SE. Creating many types of graphical interfaces, such as tiled
graphics, is easier in the mobile edition than in standard Java.
I have been writing small, simple applications for my cellphones for about ten
years now. It's nice to be able to write your own little application for your own
Visit My Personal Website,
saundby.com
D O W NL O A D S
Source code provided in articles
can be downloaded at:
My Code Page.
B A S I C J A V A A R T I C L E S
Java Documentation
The Java Language Manual
Java's Reference Manual
Source, Object, Byte Code
The Java Virtual Machine
Code Blocks
Basic Program Skeleton
Those Pesky Semicolons
Parens, Brackets, & Braces
main()
Comments
import Statements
Stars in import Statements
Primitive Variables
Creating a Java Variable
The void Type
Your Own Classes
Reference Types
Method Identifiers (signatures)
Share
1

More

Next Blog Create Blog

Sign In
A B E GI NNI NG P R OGR AM M E R ' S GU I D E
T O J AV A
J AV A P RO GRAM M I N G M Y S TE RI E S E X P L AI N E D F O R THO S E L E ARN I N G TO P RO GRAM F O R THE F I RS T TI M E ,
AN D F O R E X P E RI E N C E D P RO GRAM M E RS J US T L E ARN I N G J AV A
Showing posts with label applet. Show all posts
5/23/2014 A Beginning Programmer' s Guide to Java: applet
http://beginwithjava.blogspot.ca/search/label/applet 2/7
unique needs. I started writing Java applications for my Nokia 3650, called a
"feature phone" at the time I got it. It was a Symbian Series 60 phone that ran
an early version of Java ME with a very basic library of GUI features.
My next phone was a step up the Java ladder. It was a Sciphone G2, a fake
Android phone. I didn't mind that it was "fake", it ran a real version of Java ME
with updated GUI capabilities, which made it far easier to write applications
for.
My current phone is a Blackberry Curve 8900. It runs Java ME with all the latest
bells and whistles, plus a lot of Blackberry add-ons that make it easy to access
the phone's features.
With my Nokia, I had a special Java development environment provided by
Nokia that included a simulation of my phone, so that I could see how my
programs would run before I put them on the phone. With the G2 I was on my
own. I ran a standard Java ME development environment from within Eclipse, a
great Java integrated development environment. The version linked above is a
version specific to Java ME.
Now I'm back to having a development environment provided by my phone's
maker. I have a program that simulates my phone on my computer, which again
allows me to try out my programs before I put them on the phone (with my G2 I
tested them as well as I could, then loaded them on the phone and hoped for
the best.) It is build on Eclipse, so it is still very familiar. There is also a slew of
information on the Blackberry site (linked above) about Java development.
Unfortunately, the tutorials on the site don't exactly match the actual current
version of the software, but it's close enough it's not too hard to figure out.
One thing that confused me, however, is the installation instructions. I thought
I had to install the version of Eclipse they called for before installing the
"Blackberry Java Eclipse Add-On". It's an add-on, right?
Well, it turns out that the "add-on" from Blackberry is actually the entire thing,
Eclipse and all. So you just need to do that one download to get the
development environment. Then download the simulator for your phone and
any others you want to test your software on. Finally, apply for a signature key
to make it so that you can "sign" your software to allow it to be installed on the
phone through the software manager or Over The Air (OTA) when using the
Blackberry-specific libraries.
If you'd rather not do this, you can develop software using a plain-jane version
of Java ME, then transfer the software to your phone however you please. I put
the software I developed for my Sciphone G2 on the memory card for my
Blackberry, and it runs just fine.
Jonathan Giles
Java desktop links of the
week, May 19
An Infinite Number of Cats
Constructor Methods
Multiple Constructors
Save/Read File:Objects
GR A PH I C S A ND GUI A R T I C L E S
A Most Basic Graphic App
Graphics: Start with a JFrame
Drawing Lines
3 Graphics Examples
Controlling Graphics
A Simple Video Game Kernel
Getting Keyboard Input
Simple Mouse Interaction
UI Listeners
Image Load and Display
Rotating an Image
Java2D
Java 3D Options
B L O G A R C H I V E
2013 (2)
2012 (7)
2011 (12)
October (1)
Mobile Java
September (1)
June (2)
May (4)
April (1)
March (1)
January (2)
2010 (15)
2009 (8)
2008 (34)
MY B L O G L I S T
5/23/2014 A Beginning Programmer' s Guide to Java: applet
http://beginwithjava.blogspot.ca/search/label/applet 3/7
Translating applications between Java SE and Java ME can be simple for ones
with minimal amounts of graphics, like programs that mainly use text, buttons,
and text entry boxes for communication. Things like games, with a more
involved use of graphics, take more effort to translate between the two
versions of Java. For these, I usually re-use the game logic code without
changes, then rewrite the graphical display parts of the program from scratch.
Because I use good object-oriented coding practices (most of the time), this
isn't too much effort.
Java ME applets are easy to translate, though I write almost all of my Java
software as applications now.
POSTED BY MARK GRAYBI LL AT 7:47 PM
LABELS: APPLET, APPLI CATI ON, BEGI NNER, ENVI RONMENT, JAVA, JAVA VERSI ON, JVM,
SOURCE CODE, VI DEO GAME, WHY JAVA

submit

0
Tweet 0
T H UR S D A Y , J UNE 19, 2008
main()
There are two basic types of Java programs: applets and applications.* Applets
run through a browser or a special program called AppletViewer. Applications
are stand-alone programs that run on the same system they're stored on, like
most traditional programs. Since there's lots of information elsewhere on
applets, we'll concern ourselves mostly with applications.
Every application has a special method called main(). The main() method marks
the starting point in the program for the Java Virtual Machine. Here's a short
example program:
public class Hello{
public static void main(String arg[]){
System.out.println("Hello");
}
}
When this program is compiled using javac then run with the command
>java Hello
the JVM loads Hello.class and looks in it for the main() method, then starts
executing the code inside main()'s code block.
Now, you'll notice there's a bunch of other stuff with main():
on Keyboards
Kerbal Space Program + DayZ
= ...Firefly?
Net 4 JAVA
JQuery Element Selector
Sergey Malenkov's Blog
After JavaOne
A B O UT ME
MA RK GRA Y BI LL
Follow
0
Aerospace
engineer and part
time instructor in computers,
astronomy, and cartooning.
Amateur astronomer and radoi
amateur, call sign W8BIT.
VI EW MY COMPLETE PROFI LE

My Reviews:
Head First Java
Java Programming for the
Absolute Beginner
Beginning Programming in Java
for Dummies
S UB S C R I B E T O
Sign Up to see what your f riends like. Like Share
Posts
All Comments
5/23/2014 A Beginning Programmer' s Guide to Java: applet
http://beginwithjava.blogspot.ca/search/label/applet 4/7
public static void main(String arg[]){
Because of how Java works, that stuff has to be there in a Java application. You
can't just put "main(){" on the line by itself. The other stuff has a purpose,
though it all looks very confusing, and certainly it looks like a lot of extra junk in
a short program.
public allows the method to be accessed from outside the class (and its
package--we'll get into that later.) If you leave out public, the JVM can't access
main() since it's not available outside of Hello.
static says that this is the one and only main() method for this entire class (or
program). You can't have multiple main()s for a class. If you leave static out,
you'll get an error.
void says that main() doesn't pass back any data. Since the JVM wouldn't know
what to do with any data, since it's not set up to accept data from main(),
main() has to be of type void, which is to say that it's a method that doesn't
pass any data back to the caller. If you leave this out main() won't have a data
type, and all methods have to have a data type, even if it's void.
Inside main()'s parentheses is String arg[]. This is a way for the program to
accept data from the host system when it's started. It's required that main() be
able to accept data from the system when starting. And the data must be in
the form of an array of Strings (or a variable-length list of Strings as of Java 5,
but that's something we'll save for later.) The name "arg" can be whatever you
want to make it. It's just a name I've given the array. It could just as well be:
public static void main(String fred[]){
I'd just have to be sure to use fred whenever I wanted to access the
information that the system has passed to my application when it started,
instead of arg.
Finally, after the parentheses, comes the open curly brace { that marks the
start of main()'s code block.
* There are other types as well, but I'm limiting my discussion to Java SE/client
side stuff for now.
POSTED BY MARK GRAYBI LL AT 2:55 PM
LABELS: APPLET, APPLI CATI ON, ARGUMENTS, JVM, MAI N(), METHOD, PUBLI C, STATI C,
VOI D
5/23/2014 A Beginning Programmer' s Guide to Java: applet
http://beginwithjava.blogspot.ca/search/label/applet 5/7
Older Posts

submit

0
Tweet 0
Home
Subscribe to: Posts (Atom)

S UB J E C T S :
Android (2)
angle brackets (1)
API (14)
applet (2)
application (14)
arguments (2)
array (3)
array initializer (1)
assignment (3)
asterisk (2)
beginner (8)
book review (4)
calculations (4)
classes (8)
code blocks (3)
collection (6)
collision detection (3)
command line (7)
Comments (1)
comparison (3)
constants (1)
constructor (2)
curly braces (3)
dates (1)
declaration (4)
documentation (3)
dot notation (1)
embedded (1)
environment (10)
equals (2)
events (3)
example (2)
expressions (2)
file (3)
file names (1)
framework (3)
generics (2)
Sign Up to see what your f riends like. Like Share
5/23/2014 A Beginning Programmer' s Guide to Java: applet
http://beginwithjava.blogspot.ca/search/label/applet 6/7
graphics (21)
graphics Swing CSS (1)
heavyweight component (1)
humor (1)
i/o (3)
IDE (8)
import (2)
inheritance (2)
initializer (1)
inner class (5)
input (5)
interface (3)
Java (26)
Java version (7)
JDK (5)
JFrame (6)
JPanel (7)
JVM (10)
lightweight component (2)
List (3)
listeners (3)
literal (1)
local (1)
loop (2)
main() (4)
Math (3)
method (4)
methods (2)
modulo (1)
mouse (1)
name (2)
numeric (2)
object code (1)
objects (3)
operators (4)
output (3)
packages (5)
paint() (3)
paintComponent() (4)
parentheses (1)
percent sign (2)
public (2)
read (2)
reference (8)
regular expressions (1)
Resources (5)
restore (1)
save (1)
Scanner (1)
semicolons (1)
signature (4)
source code (4)
square brackets (1)
star (1)
static (2)
System.out.println() (2)
threads (2)
5/23/2014 A Beginning Programmer' s Guide to Java: applet
http://beginwithjava.blogspot.ca/search/label/applet 7/7
trigonometry (1)
type (8)
variables (9)
video game (8)
virtual machine (2)
void (2)
web (1)
why java (8)