From: Scott H. <sl...@ho...> - 2001-08-31 16:22:53
|
I am trying to create a jython applet. I am running Windows 2000 pro = with Sun's JDK 1.3.1 and I have tried both Jython 2.0 and 2.1a3. My = code runs fine when I execute it with Jython, but when comiling it into = the applet with (I have only one .py file named dlClient.py): jython --compiler javac --all --jar downloadClient.jar *.py The .jar is created, but it gives a warning about using a deprecated = API. Then when I try to execute it with the appletviewer, I get an = error that says: java.lang.ClassCastException: dlClient Can anyone tell me what I am doing wrong? Below, I have posted the code = for the .py file as well. from java import applet from java.awt import Color,Label,Button,GridLayout,Label from urllib import urlretrieve import time class downloadClient(applet.Applet): def init(self): try: self.setLayout(GridLayout(0,1)) self.title =3D self.add(Label('Download Test', Label.CENTER)) self.title.setBackground(Color.blue) self.title.setForeground(Color.white) self.add(Label('Beginning Download ...')) # this file is 45.7k in size self.startTime =3D time.time() rValue =3D urlretrieve("http://localhost/reports/detail.pdf") rValue =3D urlretrieve("http://localhost/reports/detail.pdf") rValue =3D urlretrieve("http://localhost/reports/detail.pdf") self.endTime =3D time.time() self.elapsedTime =3D int(self.endTime - self.startTime) self.kPerSec =3D int(137.1/self.elapsedTime) self.add(Label('Download Complete')) self.add(Label('Amount Downloaded: 137.1 KB')) self.add(Label('Time Elapsed: ' + str(self.elapsedTime) + ' = seconds')) self.totalSpeed =3D self.add(Label('Total Speed: ' + = str(self.kPerSec) + ' KB/Sec')) self.totalSpeed.setBackground(Color.yellow) #self.totalSpeed.setForeground(Color.blue) except: pass if __name__ =3D=3D '__main__':=20 import pawt pawt.test(downloadClient()) |
From: Robert W. B. <rb...@di...> - 2001-08-31 21:50:17
|
Hello Scott, Your file is "dlClient.py" and your class is "downloadClient." Try it with matching filename and classname instead. A jythonc-compiled module must meet special restrictions to play nice in a Java framework, even though these restrictions don't apply to Jython- as you have already seen. Matching filename-classname is one of them. On Fri, 31 Aug 2001, Scott Hathaway wrote: > I am trying to create a jython applet. I am running Windows 2000 pro > with Sun's JDK 1.3.1 and I have tried both Jython 2.0 and 2.1a3. My > code runs fine when I execute it with Jython, but when comiling it into > the applet with (I have only one .py file named dlClient.py): > > jython --compiler javac --all --jar downloadClient.jar *.py > > The .jar is created, but it gives a warning about using a deprecated API. Then when I try to execute it with the appletviewer, I get an error that says: > > java.lang.ClassCastException: dlClient > > Can anyone tell me what I am doing wrong? Below, I have posted the code for the .py file as well. > > from java import applet > from java.awt import Color,Label,Button,GridLayout,Label > from urllib import urlretrieve > import time > > class downloadClient(applet.Applet): > def init(self): > try: > self.setLayout(GridLayout(0,1)) > self.title = self.add(Label('Download Test', Label.CENTER)) > self.title.setBackground(Color.blue) > self.title.setForeground(Color.white) > self.add(Label('Beginning Download ...')) > # this file is 45.7k in size > self.startTime = time.time() > rValue = urlretrieve("http://localhost/reports/detail.pdf") > rValue = urlretrieve("http://localhost/reports/detail.pdf") > rValue = urlretrieve("http://localhost/reports/detail.pdf") > self.endTime = time.time() > self.elapsedTime = int(self.endTime - self.startTime) > self.kPerSec = int(137.1/self.elapsedTime) > self.add(Label('Download Complete')) > self.add(Label('Amount Downloaded: 137.1 KB')) > self.add(Label('Time Elapsed: ' + str(self.elapsedTime) + ' seconds')) > self.totalSpeed = self.add(Label('Total Speed: ' + str(self.kPerSec) + ' KB/Sec')) > self.totalSpeed.setBackground(Color.yellow) > #self.totalSpeed.setForeground(Color.blue) > except: > pass > > if __name__ == '__main__': > import pawt > pawt.test(downloadClient()) > |
From: Scott H. <sl...@ho...> - 2001-08-31 22:35:26
|
Robert, Thanks for the reply. Only the .jar file is a different name. I have tried renaming the .jar to the name of the class too, without success. I get the exact same error. Any other ideas? Thanks, Scott ----- Original Message ----- From: "Robert W. Bill" <rb...@di...> To: "Scott Hathaway" <sl...@ho...> Cc: <jyt...@li...> Sent: Friday, August 31, 2001 4:49 PM Subject: Re: [Jython-users] help with jython and creating an applet > Hello Scott, > > Your file is "dlClient.py" and your class is "downloadClient." Try it > with matching filename and classname instead. A jythonc-compiled module > must meet special restrictions to play nice in a Java > framework, even though these restrictions don't apply to Jython- as > you have already seen. Matching filename-classname is one of them. > > > On Fri, 31 Aug 2001, Scott Hathaway wrote: > > I am trying to create a jython applet. I am running Windows 2000 pro > > with Sun's JDK 1.3.1 and I have tried both Jython 2.0 and 2.1a3. My > > code runs fine when I execute it with Jython, but when comiling it into > > the applet with (I have only one .py file named dlClient.py): > > > > jython --compiler javac --all --jar downloadClient.jar *.py > > > > The .jar is created, but it gives a warning about using a deprecated API. Then when I try to execute it with the appletviewer, I get an error that says: > > > > java.lang.ClassCastException: dlClient > > > > Can anyone tell me what I am doing wrong? Below, I have posted the code for the .py file as well. > > > > from java import applet > > from java.awt import Color,Label,Button,GridLayout,Label > > from urllib import urlretrieve > > import time > > > > class downloadClient(applet.Applet): > > def init(self): > > try: > > self.setLayout(GridLayout(0,1)) > > self.title = self.add(Label('Download Test', Label.CENTER)) > > self.title.setBackground(Color.blue) > > self.title.setForeground(Color.white) > > self.add(Label('Beginning Download ...')) > > # this file is 45.7k in size > > self.startTime = time.time() > > rValue = urlretrieve("http://localhost/reports/detail.pdf") > > rValue = urlretrieve("http://localhost/reports/detail.pdf") > > rValue = urlretrieve("http://localhost/reports/detail.pdf") > > self.endTime = time.time() > > self.elapsedTime = int(self.endTime - self.startTime) > > self.kPerSec = int(137.1/self.elapsedTime) > > self.add(Label('Download Complete')) > > self.add(Label('Amount Downloaded: 137.1 KB')) > > self.add(Label('Time Elapsed: ' + str(self.elapsedTime) + ' seconds')) > > self.totalSpeed = self.add(Label('Total Speed: ' + str(self.kPerSec) + ' KB/Sec')) > > self.totalSpeed.setBackground(Color.yellow) > > #self.totalSpeed.setForeground(Color.blue) > > except: > > pass > > > > if __name__ == '__main__': > > import pawt > > pawt.test(downloadClient()) > > > > |
From: Robert W. B. <rb...@di...> - 2001-08-31 23:06:22
|
On Fri, 31 Aug 2001, Scott Hathaway wrote: > Robert, > > Thanks for the reply. Only the .jar file is a different name. I have tried > renaming the .jar to the name of the class too, without success. I get the > exact same error. > > Any other ideas? If you are sure that the class name and the name of the file that contains it matches (e.g. "dlClient.py" contains "class dlClient"), then I'm short on ideas. But I get 3 guesses don't I? GUESS #2: Maybe the browser isn't actually using the Java plugin. Because browsers don't come with out-of-the-box support for the JDK 1.3.1 you are using, you must make sure the plug-in is really installed and being used. Without the plug-in, use JDK1.1.8 to compile Jython applets. I hope this works. I don't really have a third guess <G> -robert > ----- Original Message ----- > From: "Robert W. Bill" <rb...@di...> > To: "Scott Hathaway" <sl...@ho...> > Cc: <jyt...@li...> > Sent: Friday, August 31, 2001 4:49 PM > Subject: Re: [Jython-users] help with jython and creating an applet > > > > Hello Scott, > > > > Your file is "dlClient.py" and your class is "downloadClient." Try it > > with matching filename and classname instead. A jythonc-compiled module > > must meet special restrictions to play nice in a Java > > framework, even though these restrictions don't apply to Jython- as > > you have already seen. Matching filename-classname is one of them. > > > > > > On Fri, 31 Aug 2001, Scott Hathaway wrote: > > > I am trying to create a jython applet. I am running Windows 2000 pro > > > with Sun's JDK 1.3.1 and I have tried both Jython 2.0 and 2.1a3. My > > > code runs fine when I execute it with Jython, but when comiling it into > > > the applet with (I have only one .py file named dlClient.py): > > > > > > jython --compiler javac --all --jar downloadClient.jar *.py > > > > > > The .jar is created, but it gives a warning about using a deprecated > API. Then when I try to execute it with the appletviewer, I get an error > that says: > > > > > > java.lang.ClassCastException: dlClient > > > > > > Can anyone tell me what I am doing wrong? Below, I have posted the code > for the .py file as well. > > > > > > from java import applet > > > from java.awt import Color,Label,Button,GridLayout,Label > > > from urllib import urlretrieve > > > import time > > > > > > class downloadClient(applet.Applet): > > > def init(self): > > > try: > > > self.setLayout(GridLayout(0,1)) > > > self.title = self.add(Label('Download Test', Label.CENTER)) > > > self.title.setBackground(Color.blue) > > > self.title.setForeground(Color.white) > > > self.add(Label('Beginning Download ...')) > > > # this file is 45.7k in size > > > self.startTime = time.time() > > > rValue = urlretrieve("http://localhost/reports/detail.pdf") > > > rValue = urlretrieve("http://localhost/reports/detail.pdf") > > > rValue = urlretrieve("http://localhost/reports/detail.pdf") > > > self.endTime = time.time() > > > self.elapsedTime = int(self.endTime - self.startTime) > > > self.kPerSec = int(137.1/self.elapsedTime) > > > self.add(Label('Download Complete')) > > > self.add(Label('Amount Downloaded: 137.1 KB')) > > > self.add(Label('Time Elapsed: ' + str(self.elapsedTime) + ' > seconds')) > > > self.totalSpeed = self.add(Label('Total Speed: ' + str(self.kPerSec) > + ' KB/Sec')) > > > self.totalSpeed.setBackground(Color.yellow) > > > #self.totalSpeed.setForeground(Color.blue) > > > except: > > > pass > > > > > > if __name__ == '__main__': > > > import pawt > > > pawt.test(downloadClient()) > > > > > > > > |
From: Mats W. <ma...@la...> - 2001-09-01 20:47:19
|
>GUESS #2: >Maybe the browser isn't actually using the Java plugin. Because >browsers don't come with out-of-the-box support for the JDK 1.3.1 >you are using, you must make sure the plug-in is really installed >and being used. Without the plug-in, use JDK1.1.8 to compile >Jython applets. To jump in with a question, I've had lots of trouble with the Java plugin (like, I've never actually made an applet work; the plugin itself appears to come alive as the little icon appears in my tool tray on Win2k). Does anyone have a recipe for making it work? |
From: dman <ds...@ri...> - 2001-09-01 22:05:18
|
On Sat, Sep 01, 2001 at 06:50:51AM -0400, Mats Wichmann wrote: | | >GUESS #2: | >Maybe the browser isn't actually using the Java plugin. Because | >browsers don't come with out-of-the-box support for the JDK 1.3.1 | >you are using, you must make sure the plug-in is really installed | >and being used. Without the plug-in, use JDK1.1.8 to compile | >Jython applets. | | To jump in with a question, I've had lots of trouble with the | Java plugin (like, I've never actually made an applet work; | the plugin itself appears to come alive as the little icon | appears in my tool tray on Win2k). Does anyone have a recipe | for making it work? Are you using netscape? If so then you can display the "java console" which is a window showing stdout and stderr. You are probably having classpath problems. -D |