//Following is the error log I receive
java.lang.NullPointerException
at sun.plugin2.applet.Plugin2Manager.findAppletJDKLevel(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception: java.lang.NullPointerException
//
Below is the
Java Code
import java.applet.Applet;
import java.applet.AppletContext;
import java.awt.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.ImageObserver;
import javax.swing.*;
import ChartDirector.*;
public class CERMeter extends Applet{
String finalImage=null;
Graphics graphics=null;
Image image;
Image image1;
ImageObserver obs ;
public void init()
{
}
//Name of demo program
public String toString() {
return "CER Meter";
}
//Number of charts produced in this demo
public int getNoOfCharts() {
return 1;
}
//Main code for creating charts
public Image createChart(ChartViewer viewer, int index)
{
// The value to display on the meter
double value = 60;
// Create an AugularMeter object of size 200 x 200 pixels, with silver
// background, black border, 2 pixel 3D depressed border and rounded corners.
AngularMeter m = new AngularMeter(200, 200, Chart.silverColor(), 0x000000, -2
);
m.setRoundedFrame();
// Set the meter center at (100, 100), with radius 85 pixels, and span from
// -135 to +135 degress
m.setMeter(100, 100, 85, -135, 135);
// Meter scale is 0 - 100, with major tick every 10 units, minor tick every 5
// units, and micro tick every 1 units
m.setScale(0, 100, 10, 5, 1);
// Disable default
angular arc by setting its width to 0. Set 2 pixels line
// width for major tick, and 1 pixel line width for minor ticks.
m.setLineWidth(0, 2, 1);
// Set the circular meter surface as metallic blue (9999DD)
m.addRing(0, 90, Chart.metalColor(0x9999dd));
// Add a blue (6666FF) ring between radii 88 - 90 as decoration
m.addRing(88, 90, 0x6666ff);
// Set 0 - 60 as green (99FF99) zone, 60 - 80 as yellow (FFFF00) zone, and 80
// - 100 as red (FF3333) zone
m.addZone(0, 60, 0x99ff99);
m.addZone(60, 80, 0xffff00);
m.addZone(80, 100, 0xff3333);
// Add a text label centered at (100, 135) with 15 pts Arial Bold font
m.addText(100, 135, "CER", "Arial Bold", 15, Chart.TextColor, Chart.Center);
// Add a text box centered at (100, 165) showing the value formatted to 2
// decimal places, using white text on a black background, and with 1 pixel
// 3D depressed border
m.addText(100, 165, m.formatValue(value, "2"), "Arial", 8, 0xffffff,
Chart.Center).setBackground(0x000000, 0x000000, -1);
// Add a semi-transparent blue (40333399) pointer at the specified value
m.addPointer(value, 0x40333399);
// Output the chart
viewer.setImage(m.makeImage());
image=m.makeImage();
return image;
}
public void paint(Graphics g){
CERMeter demo = new CERMeter();
ChartViewer viewer = new ChartViewer();
image1=demo.createChart(viewer, 0);
//graphics = image.getGraphics();
g.drawImage(image1,100,100,this);
}
public CERMeter()
{
}
}
//Below is the
JSP Code which I call to Load
Applets
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" import="ChartDirector.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<table width="90%" border="0" align ="center" cellpadding="5" cellspacing="0">
<tr>
<td align="center" >
<APPLET CODE="CERMeter.class" HEIGHT=200 WIDTH=310>
</APPLET>
</td>
</body>
</html>
//*********Code Ends****************//
In Java when I run as Applet it runs fine but when I run through JSP It gives above error.
I have Included ChartDirector.jar and both JSP and JavaClass are in same folder.
Please help me to resolve the same.
Looking forward for an earliest reply
Regards
Anurag Pathak
pathak_arg@yahoo.com