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!
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);
}
}
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:)
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
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
> 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 :-)
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
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.
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!!!");
}
}
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
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
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>
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
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 ......
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