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