Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting Error Class not found error

Status
Not open for further replies.

Bygbobbo

Programmer
Apr 23, 2002
145
US
I just updated to j2sdk1.4 from 1.3.
All paths are correct I can compile servlets, applets and standalones.
But When I attemp to view newly compiled Applets I get class StringViewer not found error in my browser status bar..

Here is the html:
<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;>
<HTML>
<HEAD>
<TITLE> Writing Test Applets </TITLE>
<META NAME=&quot;Generator&quot; CONTENT=&quot;EditPlus&quot;>
<META NAME=&quot;Author&quot; CONTENT=&quot;&quot;>
<META NAME=&quot;Keywords&quot; CONTENT=&quot;&quot;>
<META NAME=&quot;Description&quot; CONTENT=&quot;&quot;>
</HEAD>

<BODY>
<p align=center>
<applet code=&quot;StringViewer2&quot; width=100 height=50>
<PARAM NAME=&quot;timer&quot; value=&quot;50&quot;>
<PARAM NAME=&quot;viewer&quot; value=&quot;Hi there its tuesday&quot;>
</applet>
</BODY>
</HTML>

Here is the applet which works fine untill I recompile it with 1.4 ( I do not get any compile errors and the compiled class appears in the same directory after I compile it:

import java.applet.Applet;
import java.awt.*;
import java.util.StringTokenizer;
import java.lang.reflect.Array;


public class StringViewer extends Applet implements Runnable{
String timer, viewer;
String buffer[];
int y_position[];
int startOver;
Thread Me;
public void init(){
timer = null;
viewer = null;
try{
if (getParameter(&quot;timer&quot;) != null){
timer = getParameter(&quot;timer&quot;);
} else{
timer = &quot;1000&quot;;
}
if (getParameter(&quot;viewer&quot;) != null){
StringTokenizer viewer = new StringTokenizer(getParameter(&quot;viewer&quot;));
startOver = viewer.countTokens();
buffer = new String[startOver];
y_position = new int[startOver];
int advancing = 55;
for (int i = 0; i < startOver; i++){
buffer = viewer.nextToken();
y_position = advancing;
advancing = advancing + 20;
}
} else {
viewer = &quot;No applet string input&quot;;
}
} catch (Exception e){
System.out.println(&quot;input parameters not excepted&quot;);
}
}
public void start(){
if (Me == null){
Me = new Thread(this);
Me.setPriority(Thread.MIN_PRIORITY);
Me.start();
}
}
public void run(){
//String word[] = new String[4];
while (Me != null){
try{
Me.sleep(Integer.parseInt(timer));
if (y_position[Array.getLength(y_position) - 1] < 0){
int cycle = 65;
for (int x = 0; x < startOver; x++){
y_position[x] = cycle;
cycle = cycle + 20;
}
}else{
for (int y = 0; y < startOver; y++){
y_position[y] = y_position[y] - 1;
}
}
}catch (InterruptedException e){
System.out.print(&quot;error in string&quot;);
}
repaint();
}
}
public void stop(){
if (Me != null && Me.isAlive()){
//Me.stop();
Me = null;
repaint();
}
//addItem(&quot;stopping....&quot;);
}
public void destroy(){
Me = null;
}


public void paint(Graphics g){
g.drawRect(0,0, getSize().width -1, getSize().height -1);
g.setFont( new Font(&quot;Serif&quot;, Font.BOLD + Font.ITALIC, 20));
g.setColor( Color.red);
for (int k = 0;k < startOver ; k++){
g.drawString(buffer[k].toString(), 15, y_position[k]);

}
}

}

Any help would be greatly appreciated

Thanks in advance,

Bygs :)
 
Hi Bygbobbo,
You are using
Code:
StringViewer2
in the applet tag, but you're class is called
Code:
StringViewer
. Is this an error in the post or is this from the code?
Also, I believe that it should be:
Code:
<applet code=&quot;StringViewer.class&quot; width=100 height=50>
Hope this helps,
MarsChelios
 
I cut and pasted to fast(error in the post). I was using both StringViewer2 and StringViewer they both contain the same code, except i was using StringViewer2 as a copy to mess around with(as you will see below).

Having &quot;.class&quot; doesn't make a difference. I did try that before my post though..

Maybe this will help.. The same code compiled in 1.3 works fine-- when compiled with 1.4 it does not work, basically meaning I dont think its a syntax error.

I followed the code with System.out.prints and have come to the conclusion that it is in the Graphics Class when I paint to the screen.

------------------------------------------------------------import java.applet.Applet;
import java.awt.*;
import java.util.StringTokenizer;
import java.lang.reflect.Array;


public class StringViewer2 extends Applet implements Runnable{
String timerin = new String(&quot;50&quot;);
String viewerin = new String(&quot;This should work I should be bigger&quot;);
String timer,viewer;
String buffer[];
int y_position[];
int startOver;
Thread Me;
public void init(){
timer = null;
viewer = null;
try{
//if (getParameter(&quot;timer&quot;) != null){
if (timerin != null){
//timer = getParameter(&quot;timer&quot;);
timer = timerin;
} else{
timer = &quot;1000&quot;;
}
//if (getParameter(&quot;viewer&quot;) != null){
if (viewerin != null){
//if (view != null){
//StringTokenizer viewer = new StringTokenizer(getParameter(&quot;viewer&quot;));
StringTokenizer viewer = new StringTokenizer(viewerin);
startOver = viewer.countTokens();
buffer = new String[startOver];
y_position = new int[startOver];
int advancing = 55;
for (int i = 0; i < startOver; i++){
buffer = viewer.nextToken();
y_position = advancing;
advancing = advancing + 20;
System.out.print(&quot;buffer[&quot;+i+&quot;]: &quot;+buffer+&quot; y_position[&quot;+i+&quot;]: &quot;+y_position+&quot;\n&quot;);
}
} else {
viewer = &quot;No applet string input&quot;;
}
} catch (Exception e){
System.out.println(&quot;input parameters not excepted&quot;);
}
}
public void start(){
if (Me == null){
Me = new Thread(this);
Me.setPriority(Thread.MIN_PRIORITY);
System.out.print(&quot;Go \n&quot;);
Me.start();
}
}
public void run(){
while (Me != null){
try{
Me.sleep(Integer.parseInt(timer));
System.out.print(&quot;threading \n&quot;);
if (y_position[Array.getLength(y_position) - 1] < 0){
System.out.print(&quot;Starting over \n&quot;);
int cycle = 65;
for (int x = 0; x < startOver; x++){
y_position[x] = cycle;
cycle = cycle + 20;
System.out.print(cycle+&quot;\n&quot;);
stop();
}
}else{
for (int y = 0; y < startOver; y++){
y_position[y] = y_position[y] - 1;
System.out.print(&quot;moving position \n&quot;);
}
}
}catch (InterruptedException e){
System.out.print(&quot;error in string&quot;);
}
repaint();
}
}
public void stop(){
if (Me != null && Me.isAlive()){
//Me.stop();
Me = null;
repaint();
}
//addItem(&quot;stopping....&quot;);
}
public void destroy(){
Me = null;
}


public void paint(Graphics g){
g.drawRect(0,0, getSize().width -1, getSize().height -1);
g.setFont( new Font(&quot;Serif&quot;, Font.BOLD + Font.ITALIC, 20));
g.setColor( Color.red);
for (int k = 0;k < startOver ; k++){
g.drawString(buffer[k].toString(), 15, y_position[k]);

}
}
public static void main( String args[]) {
StringViewer2 it = new StringViewer2();
System.out.print(&quot;Initial \n&quot;);
it.init();
System.out.print(&quot;Start \n&quot;);
it.start();
}
}

All the logic works fine when I view this from the command line.

thanks again,

bygs
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top