• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

It runs on appletviewer but not on applet

 
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I created a simple calculator and it runs nicely on appletviewer, but for the last few days, I can not figure out why it doesn't function on my web page.
Here's my code and you'll find the HTML below it and a link to the page it can be seen. Thanks in advance!!!


The HTML

The web page:
http://snydb2001.freeservers.com/Calc.htm
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bryan,
I have no idea right now, but I do have a question for you. Since some time I have been noticing how nicely some people can put sample code onhere. I am wondering which editor you guys are using? I'm also asking this because if I try to copy and paste the code in TextPad 4 to try things out, all characters will be put directly after eachother and I have to spend time on rearranging the code nicely.
Thanks!
Patrick
 
Ranch Hand
Posts: 347
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Patrick,
It is not a question of which editor Brian is using but how he posted his code. He used UBB tags to maintain the nice formatting. You can learn how to use UBB tags here:
http://www.magictraders.com/ubb/ubbcode.html
In particular, look at the Code Tag section.
Hope this helps.
Stephanie
 
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you look at the Java console in your browser, you'll see that it throws a NoSuchMethodException for the parseDouble method. That is because parseDouble has only been around since version 1.2 and most browsers only support 1.1 (unless they have the JRE plugin). It's a good rule of thumb to remember that 90% of the time, if your applet works in appletviewer but not in a browser, this is the reason.
 
Stephanie Grasson
Ranch Hand
Posts: 347
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Brian,
You might also want to take another look through your code. It does run in AppletViewer, but does not function properly. For example, I tried
1 + 3 =
and got the answer as 6.
Stephanie
 
Brian Snyder
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Steph and Angela.
What would you recommend rather than parseDouble?
If I do 1 + 3 a couple of times, one time or no times after start up I get 6 some of the time, but 4 most of the time. How can that be? I can't find the bug.
Thanks all for the help!!!
 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ALL
I have a qiuck simple question, How do you run an applet in appletviewer through DOS ??
I have JDK 1.3 on windows 98.
Thanks in advance.
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Brian,
You are having an off by one problem because your oper[] array has a 0 element, but you only start adding data to it at location 1... so when you call it the first time you need to make it access element 1, change this code ( in actionPerformed(), inside the last if statement, after you assign m to the oper[] array... ) -
Change from :

To:

Zahid,
You run appletviewer in DOS with the command :

Where somePage.html is a html file that contains the applet tag that calls the applet you want to run. Of course, appletviewer is in the jdk1.3/bin directory, so that directory will have to be in your path for the appletviewer command to work.
HTH,
-Nate
 
Angela Lamb
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Instead of parseDouble:
double num = (Double.valueOf(stringVal)).doubleValue();
[This message has been edited by Angela Ann (edited March 23, 2001).]
 
reply
    Bookmark Topic Watch Topic
  • New Topic