aspose file tools*
The moose likes Applets and the fly likes Applet Problems Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "Applet Problems" Watch "Applet Problems" New topic
Author

Applet Problems

Amey Rane
Greenhorn

Joined: Mar 21, 2007
Posts: 15
Thank you for your help.I tried installing a new java plug-in but now I am getting a run time error. Unfortunately its not showing which line has the error and since I am new to Applet development I am confused. Please look at this error and the applet code and help me out.
---------------------------------------------------------------------------
Java Plug-in 1.6.0_06
Using JRE version 1.6.0_06 Java HotSpot(TM) Client VM
User home directory = C:\Documents and Settings\arane


----------------------------------------------------
c: clear console window
f: finalize objects on finalization queue
g: garbage collect
h: display this help message
l: dump classloader list
m: print memory usage
o: trigger logging
p: reload proxy configuration
q: hide console
r: reload policy configuration
s: dump system and deployment properties
t: dump thread list
v: dump thread stack
x: clear classloader cache
0-5: set trace level to <n>
----------------------------------------------------

Value recvd = 36;tel--tel:462,845,533,845;sc--tel:76.9%:451,819,574,819;math--tel:12.8%:462,782,574,782;stew--tel:5.1%:460,828,482,828;enad--lamb:2.5%:334,176,410,176;yong--lynn:2.56%:694,311,750,311;lynn:2.56%:340,154;lamb:2.5%:198,32;tel:94.8%:195,352;5;3;tel-210-c6509-01=tel--195,352;tel-210-c6506-01=tel--462,845,533,845;NO_MATCH
Length: 15
Value = 3
Value1 = tel
VALUE = tel-210-c6509-01
VALUE = 250 375
Exception in thread "Thread-7" java.lang.NullPointerException
at sun.plugin.util.AnimationPanel.createTranslucentImage(Unknown Source)
at sun.plugin.util.AnimationPanel.createGradientShapeImage(Unknown Source)
at sun.plugin.util.AnimationPanel.initBackground(Unknown Source)
at sun.plugin.util.AnimationPanel.preloadResources(Unknown Source)
at sun.plugin.util.AnimationPanel.doPaint(Unknown Source)
at sun.plugin.util.AnimationPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.lang.ClassFormatError: Incompatible magic value 1011369281 in class file JAVA_FILES/SurfCore
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at sun.applet.AppletClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadCode(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)


----------------------------------------------------------------------------

import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class SurfCore extends Applet {

Image purdue;
Image router1;
Image router2;
Font bigFont;

String foo;
String foo2;
String arg;

String[] arguments = new String[2];

int size; // counting the no. of vlan#
int size2; // counting the no. of vlan#
int bsize;
int bsize2;

int i = 0; // for iteration
int p = 0;
int w = 0;
int n = 0;
int s = 0;
int m = 0;
int m2= 0;
int k = 0;
int l = 0;
int j = 0;
int h = 0;
int v = 0;
int q = 0;



String[] test2=new String[4];
String[] test3=new String[4];
String[] test_des=new String[4]; // split for designated router
String[] test_des2=new String[4]; // split for designated router
String[] test_des3=new String[4]; // split for designated router
String[] test_des4=new String[4]; // split for designated router
String[] test=new String[500];
String[] V_Array=new String[500];
String[] V_cord =new String[5];


String[] Temp_2 =new String[3];
String[] Temp_3 =new String[3];


int[] test_des_cord=new int[3]; // integer forms
int[] test_des_cord2=new int[3]; // integer forms

String[] btest2=new String[4];
String[] btest3=new String[4];
String[] btest_des=new String[4]; // split for designated router
String[] btest_des2=new String[4]; // split for designated router
String[] btest_des3=new String[4]; // split for designated router
String[] btest_des4=new String[4]; // split for designated router
String[] btest=new String[500];
String[] bV_Array=new String[500];
String[] bV_cord =new String[5];


String[] bTemp_2 =new String[3];
String[] bTemp_3 =new String[3];

int match_flag=0;
int bmatch_flag=0;


int[] btest_des_cord=new int[3]; // integer forms
int[] btest_des_cord2=new int[3]; // integer forms


// The colors you will use
Color redColor;
Color greenColor;
Color blackColor;
Color orangeColor;
Color blueColor;


public void init()

{
bigFont = new Font("Arial",Font.BOLD,13);

// Standard colors can be named like this
redColor = Color.red;
blackColor = Color.black;
orangeColor = Color.orange;
blueColor = Color.blue;
greenColor = Color.green;
// The following 2 lines get the Purdue topology & router image

purdue = getImage(getCodeBase(), getParameter("bgImage"));
router1 = getImage(getCodeBase(), getParameter("bgImage2"));
router2 = getImage(getCodeBase(), getParameter("bgImage3"));

arg = getParameter("vlan_num");
arguments = arg.split(">");
foo = arguments[0];
foo2= arguments[1];

test = foo.split(";");
btest = foo2.split(";");

size = Integer.parseInt(test[(test.length - 4)]);
bsize = Integer.parseInt(btest[(btest.length - 4)]);

size2 = Integer.parseInt(test[(test.length - 5)]);
bsize2 = Integer.parseInt(btest[(btest.length - 5)]);

test_des = test[1].split(":");
test_des2 = test[(test.length - 3)].split(",");
test_des3 = test_des2[0].split("--");
test_des4 = test_des3[0].split("=");

btest_des = btest[1].split(":");
btest_des2 = btest[(btest.length - 3)].split(",");
btest_des3 = btest_des2[0].split("--");
btest_des4 = btest_des3[0].split("=");


Temp_2 = test[1].split(":");
Temp_3 = Temp_2[0].split("--");

bTemp_2 = btest[1].split(":");
bTemp_3 = bTemp_2[0].split("--");



//System.out.println("Value1 = " + test_des_cord[0] + " Value2 = " +
test_des_cord[1]);
if (Temp_3[1].equals("lamb")) {
test_des_cord[0] = 212;
test_des_cord[1] = 30;
}else if (Temp_3[1].equals("lynn")) {
test_des_cord[0] = 430;
test_des_cord[1] = 199;
}else if (Temp_3[1].equals("tel")) {
test_des_cord[0] = 293;
test_des_cord[1] = 427;
}else if (Temp_3[1].equals("erht")) {
test_des_cord[0] = 48;
test_des_cord[1] = 210 ;
}

if (test_des4[0].equals("lamb-20-c6509-01")) {
match_flag = 1;
test_des_cord2[0] = 261;
test_des_cord2[1] = 132;
}else if (test_des4[0].equals("lynn-b168-c6509-01")) {
match_flag = 1;
test_des_cord2[0] = 383;
test_des_cord2[1] = 257;
}else if (test_des4[0].equals("tel-210-c6509-01")) {
match_flag = 1;
test_des_cord2[0] = 250;
test_des_cord2[1] = 375;
}else if (test_des4[0].equals("erht-5b-c6509-01")) {
match_flag = 1;
test_des_cord2[0] = 143;
test_des_cord2[1] = 266;
}
if (match_flag != 1) {
if (test_des4[1].equals("lamb")) {
test_des_cord2[0] = 307;
test_des_cord2[1] = 45;
} else if (test_des4[1].equals("lynn")) {
test_des_cord2[0] = 462;
test_des_cord2[1] = 184;
} else if (test_des4[1].equals("tel")) {
test_des_cord2[0] = 214;
test_des_cord2[1] = 476;
} else if (test_des4[1].equals("erht")) {
test_des_cord2[0] = 63;
test_des_cord2[1] = 181;
}
}

if (bTemp_3[1].equals("lamb")) {
btest_des_cord[0] = 212;
btest_des_cord[1] = 30;
}else if (bTemp_3[1].equals("lynn")) {
btest_des_cord[0] = 430;
btest_des_cord[1] = 199;
}else if (bTemp_3[1].equals("tel")) {
btest_des_cord[0] = 293;
btest_des_cord[1] = 427;
}else if (bTemp_3[1].equals("erht")) {
btest_des_cord[0] = 48;
btest_des_cord[1] = 210 ;
}

if (btest_des4[0].equals("lamb-20-c6509-01")) {
bmatch_flag = 1;
btest_des_cord2[0] = 261;
btest_des_cord2[1] = 132;
}else if (btest_des4[0].equals("lynn-b168-c6509-01")) {
bmatch_flag = 1;
btest_des_cord2[0] = 383;
btest_des_cord2[1] = 257;
}else if (btest_des4[0].equals("tel-210-c6509-01")) {
bmatch_flag = 1;
btest_des_cord2[0] = 250;
btest_des_cord2[1] = 375;
}else if (btest_des4[0].equals("erht-5b-c6509-01")) {
bmatch_flag = 1;
btest_des_cord2[0] = 143;
btest_des_cord2[1] = 266;
}
if (bmatch_flag != 1) {
if (btest_des4[1].equals("lamb")) {
btest_des_cord2[0] = 307;
btest_des_cord2[1] = 45;
} else if (btest_des4[1].equals("lynn")) {
btest_des_cord2[0] = 462;
btest_des_cord2[1] = 184;
} else if (btest_des4[1].equals("tel")) {
btest_des_cord2[0] = 214;
btest_des_cord2[1] = 476;
} else if (btest_des4[1].equals("erht")) {
btest_des_cord2[0] = 63;
btest_des_cord2[1] = 181;
}
}


//System.out.println("Value = " + size);
for (i = 0; i < size; i++) {
v = 0;
test2 = test[i+2+size2].split(":");
for (v = 0; v < 3; v++)
{
V_Array[m++] = test2[v];
}
}

for (i = 0; i < bsize; i++) {
v = 0;
btest2 = test[i+2+bsize2].split(":");
for (v = 0; v < 3; v++)
{
bV_Array[m2++] = btest2[v];
}
}

}
//System.out.println("M value = " + m);

// end init()

public void paint(Graphics g) {
//System.out.println(" MATH = " + test[(test.length - 1)]);
g.setFont(bigFont);
g.drawImage(purdue,0,0,this);
g.setColor(blackColor.brighter());
g.drawLine(585,5,585,145);
g.drawLine(586,6,586,146);
g.drawLine(585,5,875,5);
g.drawLine(585,6,875,6);
g.drawLine(585,145,875,145);
g.drawLine(585,146,875,146);
g.drawLine(875,5,875,145);
g.drawLine(876,6,876,146);
g.setColor(orangeColor.darker());
g.drawString("LEGEND",706,25);
g.setColor(blackColor.brighter());
g.drawImage(router1,593,38,null);
g.drawString("CURRENT FIRST-HOP ROUTER",665,70);
g.drawImage(router2,600,90,null);
g.drawString("IDEAL FIRST-HOP ROUTER",665,116);
if (test[(test.length - 1)].equals("YES_MATCH")) {
if (test_des_cord[0] != 0) {
g.drawImage(router1,test_des_cord[0],test_des_cord[1],null);
}
for (q = 1; q < m; q = q + 3) {
V_cord = V_Array[q+1].split(",");
g.drawString(V_Array[q], Integer.parseInt(V_cord[0])+55,
Integer.parseInt(V_cord[1])+70);
}
} else {
if (test_des_cord[0] != 0) {
g.drawImage(router1,test_des_cord[0],test_des_cord[1],null);
}
for (q = 1; q < m; q = q + 3) {
V_cord = V_Array[q+1].split(",");
g.drawString(V_Array[q], Integer.parseInt(V_cord[0])+55,
Integer.parseInt(V_cord[1])+70);
}
if (test_des_cord2[0] != 0) {
g.drawImage(router2,test_des_cord2[0],test_des_cord2[1],null);
}
}

if (btest[(btest.length - 1)].equals("YES_MATCH")) {
if (btest_des_cord[0] != 0) {
g.drawImage(router1,btest_des_cord[0],btest_des_cord[1],null);
}
for (q = 1; q < m2; q = q + 3) {
bV_cord = bV_Array[q+1].split(",");
g.drawString(bV_Array[q], Integer.parseInt(bV_cord[0])+55,
Integer.parseInt(bV_cord[1])+70);
}
} else {
if (btest_des_cord[0] != 0) {
g.drawImage(router1,btest_des_cord[0],btest_des_cord[1],null);
}
for (q = 1; q < m2; q = q + 3) {
bV_cord = bV_Array[q+1].split(",");
g.drawString(bV_Array[q], Integer.parseInt(bV_cord[0])+55,
Integer.parseInt(bV_cord[1])+70);
}
if (btest_des_cord2[0] != 0) {
g.drawImage(router2,btest_des_cord2[0],btest_des_cord2[1],null);
}
}
}
} // end class PurdueTopology
Amey Rane
Greenhorn

Joined: Mar 21, 2007
Posts: 15
36;tel--tel:462,845,533,845;sc--tel:76.9%:451,819,574,819;math--tel:12.8%:462,782,574,782;stew--tel:5.1%:460,828,482,828;enad--lamb:2.5%:334,176,410,176;yong--lynn:2.56%:694,311,750,311;lynn:2.56%:340,154;lamb:2.5%:198,32;tel:94.8%:195,352;5;3;tel-210-c6509-01=tel--195,352;tel-210-c6506-01=tel--462,845,533,845;NO_MATCH
For your reference this is how the parameter foo or foo2 will look
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42608
    
  65
I think it doesn't matter what the code does. This error:
Incompatible magic value 1011369281 in class file JAVA_FILES/SurfCore

indicates that something more fundamental is going wrong, like a corrupted class file. Can you check that all of the class files are byte for byte identical to the ones you have locally?


Ping & DNS - my free Android networking tools app
Amey Rane
Greenhorn

Joined: Mar 21, 2007
Posts: 15
I didnt get you? Are you asking me to check wether my HTML file is calling the updated version of SurfCore.class
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42608
    
  65
I'm not sure what you mean by "updated".

You should check whether all class files being used are byte for byte identical to the ones you have locally running (which I assume are working correctly). Files sometimes get corrupted during the upload to the server.
Amey Rane
Greenhorn

Joined: Mar 21, 2007
Posts: 15
No, I am actually developing on the server itself and the server itself has all the java files. How do I check whether the files are working locally without uploading them to the web server?
Amey Rane
Greenhorn

Joined: Mar 21, 2007
Posts: 15
What does incompatible magic value mean? and what does a ClassFormatError usually signify?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42608
    
  65
Well, if there's no upload step, then the files can't get corrupted during upload :-) One thing less to worry about.

The magic value consists of the first 4 bytes of the class file. It always has the same value, so if the JVM sees a different value it assumes that the class file is sorrupt, and will refuse to load it.

But the message about "JAVA_FILES/SurfCore" is strange - what is "JAVA_FILES"? That's not a package name, is it? The JVM seems to think that it's part of the qualified class name. What does your applet tag and the directory structure look like?
Amey Rane
Greenhorn

Joined: Mar 21, 2007
Posts: 15
The cgi script calling the Java Applet is in dev/cgi-bin and the Java Applet is in dev/JAVA_FILES so the folder JAVA_FILES/SurfCore.class....Do you think it is a class file error and not a programming error.
Amey Rane
Greenhorn

Joined: Mar 21, 2007
Posts: 15
This is how the HTML script is passing the two arguments which are being manipulated in the Java Applet



<param name=vlan_num value="
<param name=vlan_num2 value="
ENDF6
print "$arv2";
print "$arv2_b";
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42608
    
  65
Please post the complete applet tag -as it appears in the HTML page, not as appears in whatever script generates it- and the full directory structure - where is the HTML file, where are the class files?
 
Consider Paul's rocket mass heater.
 
subject: Applet Problems