Applet with IE 5

I just tried some java applets from a book 'Java black book' written by Steven Holzner.They are worked OK if I use appletviewer, but not IE5. Please help!
[177 byte] By [JohnNYNY] at [2007-9-26 3:01:31]
# 1

U used a JApplet? If so ,u should use the java plug-in which is defultly installed in ur c:\program files\javasoft\.

Open the plug-in property panel from the start menu,chose the advance tag,and select the jvm c:\program files\javasoft\jre2\.

Done this ,and question will not be question anymore!

Vvik at 2007-6-29 10:59:38 > top of Java-index,Archived Forums,New To Java Technology Archive...
# 2
Get JRE 1.3.1 if it's not the case. JAppelt works with this version.
-DarkLord- at 2007-6-29 10:59:38 > top of Java-index,Archived Forums,New To Java Technology Archive...
# 3

Thanks a lot for your help.

I did as you said. It did not work though.

'applet.class' could not be found when IE5 tried to load it.I double checked. The class is in the directory and I could run it by appletviewer.

Here is the code:

import java.awt.*;

import javax.swing.*;

public class applet extends JApplet

{

jpanel j;

public void init()

{

Container contentPane = getContentPane();

j = new jpanel();

contentPane.add(j);

}

}

class jpanel extends JPanel

{

jpanel()

{

setBackground(Color.white);

}

public void paintComponent (Graphics g)

{

super.paintComponent(g);

g.drawString("Hello from Swing!", 0, 60);

}

}

JohnNYNY at 2007-6-29 10:59:38 > top of Java-index,Archived Forums,New To Java Technology Archive...
# 4
its probably because u are useing methods or classes that are version 1.2 or above and ie only supports 1.1 without the plugin maybe u didnt plug the plugin right :)
xlightwavex at 2007-6-29 10:59:38 > top of Java-index,Archived Forums,New To Java Technology Archive...
# 5
You have to download Java2 Plugin to your IE, so that it can run Java2 classes and methods ... this is the only way to make it run!You can test this code on Netscape 6, it Java2 was installed by defaul, you may c your applet work there by default!!
Tamer at 2007-6-29 10:59:38 > top of Java-index,Archived Forums,New To Java Technology Archive...
# 6
You have to download Java2 Plugin to your IE, so that it can run Java2 classes and methods ... this is the only way to make it run!You can test this code on Netscape 6, it Java2 was installed by defaul, you may c your applet work there by default!!
Tamer at 2007-6-29 10:59:38 > top of Java-index,Archived Forums,New To Java Technology Archive...
# 7
You download Html converter from sun site. Convert your html file using this application which will generate new html file. Use this html file to run the applets. Download converter version 1.2 or 1.3 according to your plug-in installed in your computer.
cmetternich at 2007-6-29 10:59:38 > top of Java-index,Archived Forums,New To Java Technology Archive...
# 8

As I see you have used another class in your code which uses some infos from there:it is jpanel.In order to execute the applet you should add jpanel.class to your same directory also.In this case you have 2 class file for the applet to be vieved.

Could you post jpanel.class code here also to see what is going on?

Thanks:)

credor7 at 2007-6-29 10:59:38 > top of Java-index,Archived Forums,New To Java Technology Archive...
# 9
Get HTMLParser from Sun site. And use this to convert your HTML file. Converted file will call your JRE and then opens your Applet.
asgherali at 2007-6-29 10:59:38 > top of Java-index,Archived Forums,New To Java Technology Archive...
# 10
You mention it doesn't find your class file, have you tried setting your codebase in your applet tag explicitly to '.'? Try something like:<applet code="yourClassName.class" codebase="." width="400" height="400">Rgds,Hans.
interfr4stic at 2007-6-29 10:59:38 > top of Java-index,Archived Forums,New To Java Technology Archive...
# 11
for ie5 and nS (below 6) u need to convert ur heml using HTMLConverterFollow the foll links http://java.sun.com/products/plugin/1.3/docs/html_converter.htmland istall HTMLConverterPramod
pramod_bs at 2007-6-29 10:59:38 > top of Java-index,Archived Forums,New To Java Technology Archive...
# 12

Well friends I am also facing a simillar problem i am having a JApplet, i have converted the HTML using HTML converter. While downloading jdk1.3.1 i specified the path d:\. Coz I am having c, d & e drive on my computer. Still the jre1.3.1 and plug-in1.3.1 which comes bundled along with jdk1.3.1 is sitting under c:\program files\javasoft\jre\1.3.1 So i really dont know why this happened and is this causing me a problem from viewing the JApplet in IE 5.0. If so then what is the solution over this? And some of u suggested that i should get plug-in1.3.1 for IE 5.0, how this is to be done? This is very important and most urgent to me since my project has currently stuck at this point. so friends if u can help me asap. I will really be thankfull to you.

Thanks in advance

vkotasthane at 2007-6-29 10:59:38 > top of Java-index,Archived Forums,New To Java Technology Archive...
# 13

WHat is the error u r getting after running ur applet with HTML converter.Go to the Java COnsole of plug-in and check out the printstacktrace

For getting the Java COnsole got to Control Panel and click on Java Plugin and check "Show Java Console"

Send me the error

We can solve I think

PRamod

pramod_bs at 2007-6-29 10:59:38 > top of Java-index,Archived Forums,New To Java Technology Archive...
# 14

> I just tried some java applets from a book 'Java black

> book' written by Steven Holzner.They are worked OK

> if I use appletviewer, but not IE5.

> Please help!

You probably need to download the Java Plug-In HTML Converter for viewing them correctly in IE5. You can download it from <a><href http://java.sun.com/products/plugin/ >

. You can find instructions on converting the HTML at the same site since that's what you need to do before running the applet within your browser.

Hope this helps :-)

ravigiroti at 2007-6-29 10:59:38 > top of Java-index,Archived Forums,New To Java Technology Archive...
# 15

Once I installed and used HTMLConverter, I was able to view my applets in IE; I understand being frustrated trying to run applets outside of appletviewer. Here's my question:

Is the plugin that is mentioned the same as the HTMLConverter? I don't use a plug-in, I just convert my html, and all is well.

John

jkilbour at 2007-7-1 3:09:32 > top of Java-index,Archived Forums,New To Java Technology Archive...
# 16

Hi Pramod,

As i have already written tht I have converted HTML using HTML converter and the output is as follows:

<HTML>

<!--"CONVERTED_APPLET"-->

<!-- HTML CONVERTER -->

<OBJECT classid="clsid:CAFEEFAC-0013-0001-0000-ABCDEFFEDCBA"

WIDTH = 983 HEIGHT = 600 codebase="http://java.sun.com/products/plugin/1.3.1/jinstall-131-win32.cab#Version=1,3,1,0">

<PARAM NAME = CODE VALUE = "DistillationColumnImage.class" >

<PARAM NAME = CODEBASE VALUE = "." >

<PARAM NAME="type" VALUE="application/x-java-applet;jpi-version=1.3.1">

<PARAM NAME="scriptable" VALUE="false">

<COMMENT>

<EMBED type="application/x-java-applet;jpi-version=1.3.1" CODE = "DistillationColumnImage.class" CODEBASE = "." WIDTH = 983 HEIGHT = 600 scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3.1/plugin-install.html"><NOEMBED>

</NOEMBED>

</EMBED>

</COMMENT>

</OBJECT>

<!--

<APPLET CODE = "DistillationColumnImage.class" CODEBASE = "." WIDTH = 983 HEIGHT = 600>

</APPLET>

-->

<!--"END_CONVERTED_APPLET"-->

</HTML>

I hope there is no problem in this conversion. Or should I use following in Object tag?

<Object codebase=""theUrl/j2re-1_3_1-win.exe#Version=1,3,1,0">

where theurl is where the j2re-1_3_1-win.exe is located.

Please help me. Its very urgent.

Thanks once again.

vkotasthane at 2007-7-1 3:09:32 > top of Java-index,Archived Forums,New To Java Technology Archive...
# 17
Hey John,Even i am faced with same kind of problem I am not able to view the JApplet in IE5.0 I am also frustrated could u guide me thro' the steps how to get the JApplet to view in IE5.0.Reply awaitedThanksVijay
vkotasthane at 2007-7-1 3:09:32 > top of Java-index,Archived Forums,New To Java Technology Archive...
# 18
Hi VijayThe conversion is perfect I think.Which version of jdk/jre r u using. From ur posting I can find out that u r using 1.3 for conversion.What about jre.and have u checked the error in Java COnsole.Give me the error trace.Pramod
pramod_bs at 2007-7-1 3:09:32 > top of Java-index,Archived Forums,New To Java Technology Archive...
# 19
Do you have a BODY tag in your html document?
jkilbour at 2007-7-1 3:09:32 > top of Java-index,Archived Forums,New To Java Technology Archive...
# 20

Hi Pramod,

Well now it is working on Netscape4.78. But what it did it downloaded Plug-ins and jre1.3.1 from java.sun.com and the whole program started working well in netscape. but u know what everytime i click on the screen or rather on the applet area it is repainting the whole image and for couple of seconds the screen goes blank. I am also posting my swing program here for your view. Also I would like to know how should i proceed here-on so that the swing program also works with IE5.0. Coz my concern is is it compulsory tht a user mush have or must download Plug-in to view Swing components? If so he has to spend abt 40 kb memory on his computer just to install Plug-in is there any alternative to this? Do let me know.

thanks once again.

Vijay

P.S: the swing code:

import java.awt.*;

import java.awt.event.*;

import javax.swing.JOptionPane;

import javax.swing.*;

/*<applet code="DistillationColumn.class" codebase="." width=983 height=600>

</applet>*/

public class DistillationColumn extends JApplet

{

private ImageIcon img = new ImageIcon("distillationcolumn1.gif");

String pressurec, levelupc, flowc, leveldownc, temperaturec;

double pressure, levelup, flow, leveldown, temperature;

public void init()

{

System.out.println("Inside Init");

//Create An Anonymous Inner Class, forfor Mouse Motion Adapter

addMouseMotionListener( new MouseMotionAdapter()

{

public void mouseMoved(MouseEvent me)

{

System.out.println("Inside Mouse Moved");

showStatus("Mouse co-ordinates: " +me.getX()+", "+me.getY());

}

});

addMouseListener(new MouseAdapter()

{

public void mouseClicked(MouseEvent me)

{

System.out.println("Inside Mouse Clicked");

click(me.getX(), me.getY());

}

});

//ImageIcon img = new ImageIcon("distillationcolumn1.gif");

}

public void paint(Graphics g)

{

System.out.println("Inside Paint");

img.paintIcon(this, g, 0, 0);

}

public void click(int x, int y)

{

System.out.println("Inside Click Class");

if(x>=322 && x<=366 && y>=0 && y<= 43)

{

pressurec = JOptionPane.showInputDialog("Enter Pressure");

pressure = Double.parseDouble(pressurec);

}

else if(x>=380 && x<=420 && y>=394 && y<= 434)

{

leveldownc = JOptionPane.showInputDialog("Enter Level at bottom");

leveldown = Double.parseDouble(leveldownc);

}

else if(x>=95 && x<=137 && y>=44&& y<= 86)

{

levelupc = JOptionPane.showInputDialog("Enter Level Top");

levelup = Double.parseDouble(levelupc);

}

else if(x>=270 && x<=303 && y>=141 && y<=174)

{

flowc = JOptionPane.showInputDialog("Enter Flow");

flow = Double.parseDouble(flowc);

}

else if(x>=731 && x<=774 && y>=356 && y<=396)

{

temperaturec = JOptionPane.showInputDialog("Enter Temperature");

temperature = Double.parseDouble(temperaturec);

}

else

JOptionPane.showMessageDialog(null, "Please Click at proper place!!!");

}

}

vkotasthane at 2007-7-1 3:09:32 > top of Java-index,Archived Forums,New To Java Technology Archive...
# 21
Hi There,i dont undersatand the necessity of having a body tag in HTML for pulling an applet? Is it really required if so please let me know the details.Bye
vkotasthane at 2007-7-1 3:09:32 > top of Java-index,Archived Forums,New To Java Technology Archive...
# 22
Hey John also let me know how did u got ur JAppplet to work on IE5.0ByeVijay
vkotasthane at 2007-7-1 3:09:32 > top of Java-index,Archived Forums,New To Java Technology Archive...
# 23

Hello,

May be it's just a little problem... You must don't use "like this" the swing set or classes of JDK version > 1.1. IE5 does only support (for a long time...) the JDK 1.1 version. So, if it's your case you have three solutions:

1) Rewrite the applet to be conform to the JDK 1.1

for example :

public class Test extends JApplet

become:

public class Test extends java.applet.Applet {

...

}

use only methods that are JDK1.1 complient. In doubt see the documentation of the JDK.

2) Use the sun "Executor" (java plug in) then you will use the Sun VM not the Microsoft VM. This solution open a lot of doors because you can use easyly the most recent version of JDK. Don't forget to download the HTMLConverter if you want to use this solution.

This is a good solution. But end users must download it the first time. It size is greater than the swing set archive file but it's only one time. For me, i use this solution on a intranet. On web server it's another thing!

But like we say where i leave : we can have butter and the money of butter!

3) You can use swing set jar in your applet instead using the Sun "Executor" but the end users will download each time the swing.jar (>1Mo).

<APPLET CODE="Test.class" ARCHIVE="Test.jar, swing.jar" WIDTH=100 HEIGHT=100>

...</APPLET>

If you have problems with applet buy and excellent book from sun microsystem press written by Cay S.Horstmann and gary Cornell. You will win a lot of time!

Bests regards

fbruot at 2007-7-1 3:09:32 > top of Java-index,Archived Forums,New To Java Technology Archive...
# 24

The plug in is a solution that Sun company to solve the question that almost no browse can catch up with the step of java.So if u use the advance characters of java,such as Swing,u should use plug in .

(That why we should use AWT1.0 to write our program if u want to it work in the internet ,but if it is run in a intranet,we can use swing etc.Because we can use the plug in in a intranet ........Sorry ,i cant say it well,otherwise,sorry

Vvik at 2007-7-1 3:09:32 > top of Java-index,Archived Forums,New To Java Technology Archive...
# 25

Hi Vijay

I think ur problem is with conflict between the jre installed in ur system and HTML converter u have used to convert.

Try the Foll code for html

<HEAD>

<TITLE>DataGliderApplet</TITLE>

</HEAD>

<BODY>

<!--"CONVERTED_APPLET"-->

<!-- CONVERTER VERSION 1.3 -->

<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"

WIDTH = 700 HEIGHT = 450 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0">

<PARAM NAME = CODE VALUE = DistillationColumnImage.class >

<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3">

<PARAM NAME="scriptable" VALUE="false">

<COMMENT>

<EMBED type="application/x-java-applet;version=1.3" CODE = DistillationColumnImage.class CODEBASE = . WIDTH = 700 HEIGHT = 450 database = access scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED></COMMENT>

</NOEMBED></EMBED>

</OBJECT>

<!--

<APPLET CODE = DistillationColumnImage.class CODEBASE = . WIDTH = 700 HEIGHT = 450>

</APPLET>

-->

<!--"END_CONVERTED_APPLET"-->

</BODY>

</HTML>

pramod_bs at 2007-7-1 3:09:32 > top of Java-index,Archived Forums,New To Java Technology Archive...
# 26

Hi everyone,

Thanks for all the helps.

I've got the problem solved.The java codes are OK.

The problem is the html converter.I was/am using jdk1.3.1 and I thought I did not need the converter according to sun.I did all the download and installation about the html converter yesterday. After I convert the html everything works OK now.

I don't have all the details right now. I will try to put all steps together tonight.

Thanks for the help again.

John

JohnNYNY at 2007-7-1 3:09:32 > top of Java-index,Archived Forums,New To Java Technology Archive...
# 27

Vijay,

In Windows Control Panel, you should see "Java Plug-in 1.3.1" icon. Double click to open and in the "Basic" tab, turn on "Enable Java Plug-in". Also in "Advanced" tab, check "Java Runtime Environment", if "Use Java Plug-in Default" does not work for you, select "JRE 1.3.1 in C:\..." and make sure you have file "npjava131.dll" in C:\Program Files\JavaSoft\JRE\1.3.1\bin ......

yilin at 2007-7-1 3:09:32 > top of Java-index,Archived Forums,New To Java Technology Archive...
# 28

Hi friends,

Again another problem!!!!!!

Now JAppet it is working fine in Netscape. But a new problem has arise now. After I specify CLASSPATH for rt.jar which is d:\jdk1.3.1\jre\lib\rt.jar I am not able to run my java command(for executing any .class file) not thru my Edit Plus Editor and neither thru my command prompt. So I tried following:

1. By Clicking on System Icon in Control panel and going to Advanced tab(OS is Windows 2000 Professional) I changed the Classpath in User Variable to "." for current directory after this path I inserted a semicolon and then specified the path for jar file. Now only java command started working and when i tried to open JApplet in Netscape it started giving me error that Applet not inited. I am really frustrated now. Can you please suggest me a solution.

Thanks in advance

Vijay

vkotasthane at 2007-7-1 3:09:32 > top of Java-index,Archived Forums,New To Java Technology Archive...