Help coderanch get a
new server
by contributing to the fundraiser
  • 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

applet

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
package myPackage;
import java.applet.*;
import java.awt.*;



public class MyApplet extends Applet
{
public void paint(Graphics g)
{
g.drawString("sunanda", 100 ,100);
}



}


i am getting error as nullpointerException
 
Marshal
Posts: 79635
380
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please post more details, particularly which line your Exception occrus on.
 
sunanda kadam
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Exception in thread "main" java.lang.NullPointerException
at java.awt.Window.init(Unknown Source)
at java.awt.Window.<init>(Unknown Source)
at java.awt.Frame.<init>(Unknown Source)
at java.awt.Frame.<init>(Unknown Source)
at sun.applet.AppletViewer.<init>(Unknown Source)
at sun.applet.StdAppletViewerFactory.createAppletViewer(Unknown Source)
at sun.applet.AppletViewer.parse(Unknown Source)
at sun.applet.AppletViewer.parse(Unknown Source)
at sun.applet.Main.run(Unknown Source)
at sun.applet.Main.main(Unknown Source)
at sun.applet.AppletViewer.main(Unknown Source)
 
Campbell Ritchie
Marshal
Posts: 79635
380
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Doesn't it give line numbers on your stack trace? Is that all the code you have? Nothing else?

You are supposed to write super.paint(g); before anything else in the paint() method, but I don't think that is the cause of your problem.
 
sunanda kadam
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am buginner in java.
was trying to execute simple code in eclipse .
 
Campbell Ritchie
Marshal
Posts: 79635
380
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How did you start the application? Did you use "run as"->"Java Applet?" It works all right when I try it on Eclipse.
 
sunanda kadam
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes i started as java applet
 
Campbell Ritchie
Marshal
Posts: 79635
380
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is that the whole code? When I tried it on Eclipse it ran first time.
 
sunanda kadam
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry to ask you this agian campbell .......

this is the code i am executing
 
sunanda kadam
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
starting!
Invalid Menu Extension (Path is invalid): org.objectweb.lomboz.ws.axis.ui.action
s.wsdl2java




This is what i am getting on dos shell
 
Campbell Ritchie
Marshal
Posts: 79635
380
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you tried running it elsewhere?

Go through the Java Tutorials.

You find you have to create an html file which will read something like this, in its simplest form:

<html>
<applet code = "myPackage.MyApplet.class" width = "300" height = "150">
</applet>
</html>

Call that file MyApplet.html and save it a folder. Copy your MyApplet class into the same folder. Run it from the command line with these commands

javac -d . myApplet.java
appletviewer MyApplet.html



I have just tried it and got a grey square with "sunanda" written on.

BTW: In future use the javax.swing.JApplet class rather than Applet.
 
Campbell Ritchie
Marshal
Posts: 79635
380
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have a problem with your Eclipse installation; I am going to shift this thread to what I think is the most appropriate forum. Click on the links above and below this thread to continue.
 
Campbell Ritchie
Marshal
Posts: 79635
380
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Suggest you reinstall Eclipse as a first step. In fact I have neveer installed Eclipse on Windows myself; I simply unzip the installation into a folder, then create a shortcut from desktop to the eclipse.exe program, which you will find in the eclipse folder with the round blue icon.
 
sunanda kadam
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
applications are running properly but not the aaplets.
ther might be spme extra settings required for applets to run in eclipse
 
Campbell Ritchie
Marshal
Posts: 79635
380
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You shouldn't need any extra settings to run applets from Eclipse. Suggest you download it again. Got to go now, but shall check later to see how you have got on.
No idea what the bit about org.objectweb means; it is presumably a required class somewhere, but I have never heard of it. If you get really desperate, reinstall Java and check your PATH.
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
is that whole code???
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic