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()) > |