here is the new version V2 of the Applet booter ( that was made related to lastest Java 1.6-u19 sucks plugin release… )
Online demo here : http://demo.dzzd.net/BootV2/
Download of boot.jar here : http://demo.dzzd.net/BootV2/boot.jar
Full demo download here : http://demo.dzzd.net/BootV2/boot.zip
sidenote : I believe that to avoid those scary mixed code popup lot of people will just sign and add full rights to everything… this is why the Oracle Upadate 6u19 is so stupid…
HTML sample use below :
It load the applet “jar.MyJarApplet” and set “myJarApplet.jar;someOtherJar.jar” to its classpath, the applet should start imediatly as only boot.jar is loaded at start (approx 5KB load).
If you request to use signed an unsigned jar than you should simply have to self-sign boot.jar and you should be done, let me know… (NB: for simplicity you may make & keep two version of the boot.jar : unsignedBoot.jar and signedBoot.jar that you will use depending if you request or not signed jar)
<applet
archive = "boot.jar"
code = "Boot"
width = "500"
height = "300">
<PARAM NAME="BOOTCLASS" VALUE="jar.MyJarApplet">
<PARAM NAME="BOOTJARS" VALUE="myJarApplet.jar;someOtherJar.jar">
<PARAM NAME="BOOTFGCOLOR" VALUE="000000">
<PARAM NAME="BOOTBGCOLOR" VALUE="ffffff">
<PARAM NAME="BOOTTOSTART" VALUE="TRUE">
<PARAM NAME="boxbgcolor" VALUE="#ffffff">
<PARAM name="java_arguments" value="-Dsun.awt.noerasebackground=true">
</applet>
source :
/*
* This file is part of 3DzzD http://dzzd.net/.
*
* Released under LGPL
*
* 3DzzD is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* 3DzzD is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with 3DzzD. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2005 - 20010 Bruno Augier
*/
import java.awt.*;
import java.applet.*;
import java.awt.image.*;
import java.net.*;
import java.security.*;
import java.security.cert.*;
import java.util.*;
/**
* Boot
*
* An Applet Boot class
*
* @author Bruno Augier
* @website: http://dzzd.net/
* @version 2.00 2010/04/12
*/
public final class Boot extends Applet implements Runnable,AppletStub
{
public static final long serialVersionUID = 0x00000001;
private volatile int nbStart=0;
private volatile Graphics g;
private volatile int bgColor;
private volatile int fgColor;
private volatile Container c;
private volatile boolean loaded;
private volatile Thread t;
private volatile Applet a;
private volatile boolean bootToStart=false;
private volatile Image bImage;
private volatile Graphics bg;
private int w()
{
return this.getSize().width;
}
private int h()
{
return this.getSize().height;
}
private int blend(int color1,int color2, int factor)
{
int f1=256-factor;
return ((((color1&0xFF00FF)*f1 + (color2&0xFF00FF)*factor ) &0xFF00FF00 ) | ( ( (color1&0x00FF00)*f1 + (color2&0x00FF00)*factor ) &0x00FF0000 ) ) >>>8;
}
private volatile int nb=0;
private volatile long lTime;
public void run()
{
try
{
this.lTime=System.currentTimeMillis();
while(!this.loaded)
{
Color color=new Color(this.bgColor);
this.c.setBackground(color);
this.bg.setColor(color);
this.bg.fillRect(0,0,w(),h());
int cx=this.w()>>1;
int cy=this.h()>>1;
for(int n=0;n<360;n++)
{
/*
int b=75+n>>1;//255;
int v=75+n>>1;//165+(n>>2);
int r=75+n>>1;
r^=255;
v^=255;
b^=255;
r+=0;
v+=0;
b+=0;
*/
int RGB=blend(this.fgColor,this.bgColor,(255*n)/360);
this.bg.setColor(new Color(RGB));
double a=(nb-n*0.5)*Math.PI/180.0;
double ca=Math.cos(a);
double sa=Math.sin(a);
int x=cx+(int)(8.0*ca);
int y=cy+(int)(8.0*sa);
int x2=cx+(int)(12.0*ca);
int y2=cy+(int)(12.0*sa);
this.bg.drawLine(x,y,x2,y2);
}
this.g.drawImage(this.bImage,0,0,null);
nb+=6;
long time=System.currentTimeMillis();
long delta=time-lTime;
lTime=time;
//if(delta<20)
//Thread.sleep(20-delta);
Thread.sleep(5);
Thread.yield();
//System.out.println (nb);
}
}
catch(InterruptedException ie)
{
ie.printStackTrace();
}
}
public Applet getApplet()
{
return this.a;
}
public void paint(Graphics g)
{
if(this.nbStart++==0)
{
this.bImage=this.createImage(w(),h());
this.bg=this.bImage.getGraphics();
this.bgColor=0xFFFFFF;
this.fgColor=0x000000;
/**
* Try to enable antialias if possible
*/
try
{
((Graphics2D)this.bg).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
}
catch(Throwable t)
{
t.printStackTrace();
}
String sBgColor=this.getParameter("BOOTBGCOLOR");
if(sBgColor!=null)
{
try
{
this.bgColor=Integer.parseInt(sBgColor,16);
}
catch(Throwable t)
{
t.printStackTrace();
}
}
String sFgColor=this.getParameter("BOOTFGCOLOR");
if(sFgColor!=null)
{
try
{
this.fgColor=Integer.parseInt(sFgColor,16);
}
catch(Throwable t)
{
t.printStackTrace();
}
}
this.c=this.getParent();
this.g=this.c.getGraphics();
this.c.remove(this);
this.loaded=false;
this.t=new Thread(this);
this.t.start();
String bootToStart=this.getParameter("BOOTTOSTART");
if(bootToStart!=null && bootToStart.equals("TRUE"))
this.bootToStart=true;
String bootClass=this.getParameter("BOOTCLASS");
Color color=new Color(this.bgColor);
this.c.setBackground(color);
new AppletLoader(bootClass);
}
}
/**
* Workaround for split previous to Java 1.4
*/
private String[] split(String str,char ch)
{
if(str==null)
return null;
if(str.length()==0)
return new String[]{""};
int nb=1;
int ofs=str.indexOf(ch);
while(ofs!=-1)
{
nb++;
ofs=str.indexOf(ch,ofs+1);
}
String strings[]=new String[nb];
int numString=0;
int startIndex=-1;
for(int n=0;n<nb;n++)
{
int endIndex=str.indexOf(ch,startIndex+1);
if(endIndex==-1) endIndex=str.length();
strings[n]=str.substring(startIndex+1,endIndex);
startIndex=endIndex;
}
return strings;
}
URLClassLoader ucl;
private class AppletLoader implements Runnable
{
String name;
AppletLoader(String name)
{
this.name=name;
Thread t=new Thread(this,"DZZD APPLET BOOT");
t.start();
}
public void run()
{
try
{
Thread.sleep(100);
String bootArchive=Boot.this.getParameter("BOOTJARS");
String bootArchives[]=Boot.this.split(bootArchive,';');//.split(";");
URL urlJars[]=new URL[bootArchives.length+1];
urlJars[0]=Boot.this.getCodeBase();
for(int n=0;n<bootArchives.length;n++)
{
URL u=new URL("jar:" + Boot.this.getCodeBase() + bootArchives[n] + "!/");
urlJars[n+1]=u;
System.out.println ("Adding JAR " + u);
}
URLClassLoader ucl=null;
try
{
ucl=new BootClassLoader(urlJars);
}
catch(Throwable t)
{
ucl=((URLClassLoader) Thread.currentThread().getContextClassLoader()).newInstance(urlJars);
}
Boot.this.a=(Applet)ucl.loadClass(this.name).newInstance();
Boot.this.a.setVisible(false);
{
Boot.this.a.setStub(Boot.this);
Boot.this.c.add(Boot.this.a);
Boot.this.a.resize(new Dimension(Boot.this.w(),Boot.this.h()));
Boot.this.a.init();
if(!Boot.this.bootToStart)
Boot.this.a.setVisible(true);
Boot.this.a.start();
if(Boot.this.bootToStart)
Boot.this.a.setVisible(true);
}
Boot.this.loaded=true;
Boot.this.t.join();
}
catch(Throwable e)
{
e.printStackTrace();
}
}
}
public void start()
{
if(this.a!=null)
this.a.start();
}
public void stop()
{
if(this.a!=null)
this.a.stop();
}
public void destroy()
{
if(this.a!=null)
this.a.destroy();
this.a=null;
}
/*
public void update(Graphics g)
{
}*/
public void appletResize(int width, int height)
{
if(this.a!=null)
this.a.setSize(width,height);
}
}