Set Java$Dir <Obey$Dir>
Set File$Type_AE4 Java
Set Plugin$Type_AE4 Java
Set Plugin$About_AE4 <Obey$Dir>.About
Set JavaDLL$Path <Java$Dir>.Libraries.
Set Java$SymbolIndex <Java$Dir>.Index
Set Java$FontPath <Java$Dir>.Fonts

Run <Java$Dir>.SetVars

IconSprites <Java$Dir>.!Sprites

| Check we're running the nested window manager
RMEnsure WindowManager 3.97 Error You need the nested Window Manager (version 3.97 or later) to run Java

WimpSlot -min 3000k -max 3000k

| Check we have a recent enough FPEmulator
RMEnsure FPEmulator  4.00 RMLoad System:Modules.FPEmulator
RMEnsure FPEmulator  4.00 Error You need FPEmulator 4.00 or later to run Java

| Check if NFS is present. If it is, it must be version 2.32 or later
| to get filename munging correct
Set Java$NFSPresent True
RMEnsure NFS         0.00 Set Java$NFSPresent False
If "<Java$NFSPresent>" = "True" Then RMEnsure NFS 2.32 Error You need NFS 2.32 or later to run Java
Unset Java$NFSPresent

| Load various toolbox modules
RMEnsure Toolbox     1.23 RMLoad System:Modules.Toolbox.Toolbox
RMEnsure Toolbox     1.23 Error You need Toolbox 1.23 or later to run Java
RMEnsure Window      1.44 RMLoad System:Modules.Toolbox.Window
RMEnsure Window      1.44 Error You need Window 1.44 or later to run Java
RMEnsure Iconbar     1.12 RMLoad System:Modules.Toolbox.Iconbar
RMEnsure Iconbar     1.12 Error You need Iconbar 1.12 or later to run Java
RMEnsure SaveAs      0.12 RMLoad System:Modules.Toolbox.SaveAs
RMEnsure SaveAs      0.12 Error You need SaveAs 0.12 or later to run Java
RMEnsure Menu        0.24 RMLoad System:Modules.Toolbox.Menu
RMEnsure Menu        0.24 Error You need Menu 0.24 or later to run Java

| Load Java's toolbox extensions
RMEnsure TextGadgets 0.08 RMLoad <Java$Dir>.Resources.TextGadget
RMEnsure TextGadgets 0.08 Error You need TextGadgets 0.08 or later to run Java
RMEnsure FileDBox    1.00 RMLoad <Java$Dir>.Resources.FileDBox
RMEnsure FileDBox    1.00 Error You need FileDBox 1.00 or later to run Java

| Load Java's support module
RMEnsure JavaSupport 0.05 RMLoad <Java$Dir>.Resources.JavaSpt
RMEnsure JavaSupport 0.05 Error You need a newer Java Support module

| Load the graphics context manager
RMEnsure GCManager   1.02 RMLoad <Java$Dir>.Resources.GCManager
RMEnsure GCManager   1.02 Error You need a newer Graphics Context Manager

WimpSlot -min 1024K -max 1024K

| This isn't very nice, but allows long classnames to be passed
Set Java$Temp 0
If "%0" = "" Then Set Java$Temp 1

If "<Java$Temp>" = "1" Then Run <Java$Dir>.!RunImage -ss8k -mx<Java$MaxHeap> com.acorn.applet.AppletViewer <Java$Timeout> ><Java$Out> 2><Java$Err>

If "<Java$Temp>" = "0" Then Run <Java$Dir>.!RunImage %*0

Unset Java$Temp