Download Java Applet or Java Application

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

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

Document related concepts
no text concepts found
Transcript
Java Applet or Java Application?
My Java programs can be used as an Applet (embedded in a Web page) or as standalone Java
applications. In both cases you will need some archive files, which contain the complete
application and utility class trees. These archives come in the form of Java ARchives (.jar)
files.
Running
Applets
An applet can be run either by loading the HTML page into your Java
enabled web browser (e.g. Microsoft Internet Explorer, Netscape
Navigator, Opera, etc.) or by using the AppletViewer program provided
for several platforms by Sun Microsystems.
Running as an applet in your browser is probably the easiest way to use
the Java Programs and it offers the benefit that you will always get the
latest version over the net.
A disadvantage may be, that you cannot save, print or copy data to the
clipboard, as long as you use the standard Java security settings of your
browser. If you lower these restrictions for all Java programs, you should
reset them before surfing into the unknowns of the web in order to avoid
that someone malicious can read or write files on your computer system.
In Microsoft Internet Explorer™, you have a better option: You can
declare single web sites as "trusted" and assign individual security
restrictions (file access permission, printing permission) to them. You
have to perform the following steps to do so:






Notes:
Use the menu Extras - Internet-Options to show a dialog box and
select the Security card.
Select the green checkmark Trusted Sites and push the Sites...
button to open a new dialog box.
Here you add the web site you are trusting, e.g. http://www.mhaerotools.de/. and close the Trusted Sites dialog box.
Adjust the security settings for this Trusted Sites zone by opening a
new dialog box and another one for the Java settings:
- you should allow access for non signed applications (like
JavaFoil or JavaProp).
Closing all open dialog boxes should put the new settings into
action - Phew!
Reload the page from the site.
You will then see a
sign in the status line whenever you work with
one of the trusted sites. All other web sites will still use the safe security
settings (no checkmark).
In Netscape Navigator™ and Opera™ I could not find a way to define
individual security settings for a site. In Suns HotJava™, you can at least
allow file access, but I could not allow access to the printer (which is
ridiculous, as file access could be much more dangerous than printing).
Normally, your browser will cache the Java archive, so that you can even
run it offline after disconnecting from the net (of course only until you
clear or overflow the cache buffer).
Running
Applications
Running a program as a Java standalone application makes use of the Java
runtime environment and the Java loader, which is usually called java on
Unix or either java or wjava under Microsoft Windows. The Java loader
loads the main .class file and all related classes from the .jar archive(s),
which must be either in the same directory, in one of the directories listed
in the CLASSPATH environment variable, or you must specify the path
on the command line.
Microsoft Windows:
If you have placed an main archive file like javaprop.jar and the helper
classes mhclasses.jar in your current directory, you can run JavaProp by
entering the following command line in the DOS command prompt
window:
java -cp ./javaprop.jar;./mhclasses.jar MH.JavaProp.JavaProp
or, if these archive files are in the java subdirectory:
java -cp ./java/javaprop.jar;./java/mhclasses.jar
MH.JavaProp.JavaProp
Remark: In Microsoft Windows you can also create an icon and associate
one of the above command lines with it.
UNIX Systems:
On a UNIX system, you would probably enter a command line like (line is
folded to fit on page):
java -classpath ./javaprop.lar:./mhclasses.jar:
/usr/java/lib/rt.jar:/usr/...path... MH.JavaProp.JavaProp
The trailing classpath elements depend on your local installation; path
separator is a ":".
If you run JavaProp as a standalone application, using java, it can access
the file system, the clipboard and your printer without changing any
browser settings.
Last Resort: use the unpacked archives:
A few Java implementations may have problems with multiple .jar
archives. In this case, you can unpack these archives to a directory tree,
which will then contain the raw .class files. You will create one tree of
utility classes from mhclasses.jar starting in the directory MH under the
applet directory and all the application classes in the applet directory.
The directory structure will look similar
to the one shown at the left.
All the application classes will be in the
Applet Directory above the MH directory.
The utility classes will go into directories
of their own under the MH directory.
You can then run the main class in the Applet Directory using a command
like:
java JavaProp.class
Java
Versions and
Browsers
Some users have reported problems with Java Programs. A typical sign of
these problems were missing or badly painted scrollbars on the tables. If
you encounter such anomalies, your Java installation may be buggy or too
old. You should have at least Java 1.1, and on some Microsoft
Windows™ systems it might be necessary to update the Java virtual
machine (VM) and the runtime environment (JRE). This can be done by
installing the latest version of Internet explorer (custom setup) or by
downloading and installing these files from the Microsoft or Sun web
server (see below). There is no need to install the development toolkit
(JDK) if you do not intend to write programs in Java; in order to run Java
programs, the runtime environment (JRE) is sufficient.
The following versions have been tested and work well:








Windows 98, Sun Java 2, 1.4.1
Windows 98, IE 5.5, Java 1.1.4, Microsoft Java VM 5.0
Windows 98, Sun Java 2, 1.3.0
Windows 98, Netscape 6.0: Java 1.3.0
Windows 2000, IE 5.0, Java 1.1.4
Windows 2000, Opera 5.11, Sun Java Runtime Environment 1.3
Windows XP, IE 6.0, Sun Java Plug-in versions 1.4.2_02 to _04
HotJava for Windows, MacOS, Solaris, Version 3.0,
http://java.sun.com/products/hotjava/
Under Netscape on an IRIX machine I found a quite slow and somewhat
buggy Java VM.
Java Web Start The latest Java releases come with a technology called Java Web Start for
deploying applications via a web site. The Web Start application caches all
files so that you can later run the application without accessing the
internet.
Instructions if you have the latest Java version installed (Java
1.5)



Download and start JavaFoil automatically by clicking on this link:
JavaFoil.
Download and start JavaProp automatically by clicking on this
link: JavaProp.
Download and start JavaPipe automatically by clicking on this
link: JavaPipe.
Instructions if you have an older Java version and Java Web
Start (Java 1.4 or below)







If you want to install Java Web Start visit Suns web site at
http://java.sun.com/products/javawebstart/ for availability of Java
Web Start downloads.
Start the Java Web Start application (German version shown):
Enter the address
http://www.mh-aerotools.de/airfoils/java/ws/remoteapps.htm
into the address field and press the RETURN or the TAB key to
see all available applications.
The Web Start application will scan the address and show you all
available applications.
When you start an application for the first time, you are asked
whether you trust it and allow access to files, printer etc. If you
grant access, you can run it like a normal application.
You can later work offline, because Java Web Start will cache the
application files.
For Java 1.5 see http://www.mhaerotools.de/airfoils/java/ws/remoteapps.htm
Parameters
You can supply command line arguments to customize my Java programs. When you are
running a standalone application you can pass any desired parameters either as a command
line argument at the end of the command line, or as a system property using the -D option of
the java command. A typical command line equivalent to the <PARAM> tags in an HTML
file below would be:
java -cp .\javaprop.jar;.\mhclasses.jar -DCountry=USA -DFontSize=16 DScreenCharset=ASCII MH.JavaProp.JavaProp
or
javaw -cp .\javaprop.jar;.\mhclasses.jar -DCountry=USA -DFontSize=16 DScreenCharset=ASCII MH.JavaProp.JavaProp
The difference between java and javaw is that java blocks the command line and prints its
error messages to the command window; whereas javaw does not output error messages and
runs in a separate thread (not blocking the console).
Alternatively, if you want to use the applet version, you can use a modified HTML applet
page. Then you supply the parameters by <PARAM> tags inside the <APPLET> or
<OBJECT> tag. The HTML code looks like:
Using the <APPLET> tag
<APPLET NAME="JavaPropApplet"
CODE="MH.JavaProp.JavaProp.class"
ARCHIVE="./javaprop.jar,./mhclasses.jar"
WIDTH="600" HEIGHT="640">
<PARAM NAME="Country"
VALUE="USA">
<PARAM NAME="FontSize"
VALUE="16">
<PARAM NAME="ScreenCharset" VALUE="ASCII">
</APPLET>
Using the <OBJECT> tag
<OBJECT ID="JavaPropApplet"
CODETYPE="application/java"
CODEBASE="./javaprop.jar ./mhclasses. jar"
CLASSID="java:MH.JavaProp.JavaProp"
WIDTH="600" HEIGHT="640">
<PARAM NAME="Country"
VALUE="USA">
<PARAM NAME="FontSize"
VALUE="16">
<PARAM NAME="ScreenCharset" VALUE="ASCII">
</OBJECT>
You then use your browser to load the applet page.
You can use any of the following parameters for customization of JavaFoil and JavaProp:
Parameter Name
possible Values
ToolbarColor
#xxxxxx
Country
USA | GERMANY | FRANCE
|
CANADA | ITALY | SPAIN
FontSize
dd
ScreenCharset
ASCII | Unicode
PrinterCharset
ASCII | Unicode
Comment
hex RRGGBB color for toolbar and
status line background
country for language (default: USA)
the font size in points, used for
screen display (default: 12pt)
symbol set for screen display
(default: Unicode)
symbol set for the printer (default:
Unicode)
FileCharset
ASCII | Unicode
symbol set for file and clipboard
transfer (default: Unicode)
Symbol Set Parameters
Each Java implementation should support the full Unicode character set, but
some systems have problems with this. Typically, everything looks nice on
screen, but you may receive funny characters or black blobs on printout or in
saved files. Then you should try to set the corresponding ...Charset to ASCII.
Greek characters (available in Unicode only) will be replaced with a text
version like alfa or beta.
Additional Parameters for JavaProp:
Parameter Name
possible Values
BladeElements
dd
Comment
number of blade elements (default:
40, reasonable: 20-40)
Additional Parameters for JavaFoil:
Parameter Name
possible Values
Comment
Script
path and name of script
file
JavaFoil Scripting Edition only
How to download a Java program for usage as a standalone Application?
Instructions can be found at the bottom of each applet page.
How to get a Java Virtual Machine (VM)?
Sun offers ist VM for many platforms on its web site at http://java.sun.com/. On this web site
you should always be able to find the most recent version of the Java VM for your system.