Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7163417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:53:59+00:00 2026-05-28T13:53:59+00:00

I have a problem with java applet and graphics. I’m trying to run it

  • 0

I have a problem with java applet and graphics. I’m trying to run it in Eclipse and it fails.
Im new in java and i hope you can help me.
I have two files: Say.java and SayWhat.java.
Say.java:

public class Say {
    SayWhat word = new SayWhat("Hello World");

}

SayWhat.java:

import java.applet.Applet;
import java.awt.Graphics;

@SuppressWarnings("serial")
public class SayWhat extends Applet {
     Graphics g;
     String what;
    public SayWhat(String what) {
        this.what=what;
    }
    public void paint(Graphics g){
        g.drawString(what, 20, 20);
    }
}

Error that appears is:

load: SayWhat.class can't be instantiated.
java.lang.InstantiationException: SayWhat
    at java.lang.Class.newInstance0(Unknown Source)
    at java.lang.Class.newInstance(Unknown Source)
    at sun.applet.AppletPanel.createApplet(Unknown Source)
    at sun.applet.AppletPanel.runLoader(Unknown Source)
    at sun.applet.AppletPanel.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

Can you please tell me what am i doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T13:54:00+00:00Added an answer on May 28, 2026 at 1:54 pm

    An applet needs to have a public no-arg constructor (either by having an explicit public no-arg constructor, or by having no explicit constructors at all; in the latter case, the compiler will supply a public no-arg constructor as a default). Your class’s sole constructor takes an argument:

    public SayWhat(String what) {
    

    so the class can’t be instantiated without that argument, so it can’t be used as an applet.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a weird problem. My java applet work fine in my IDE (Eclipse),
I'm trying to use Java Applet for my website. but I have a problem
I have a Java applet related problem and I would appreciate your help. Here's
I have a problem using the Java search function in Eclipse on a particular
I have multiple pages with java applet written with SWT. The problem is, applet
I have a problem with drawing a polygon in Java applet. I don't understand
I have a problem. Sometimes when I close my Java applet using the Close
I have two class fils upload.java and transferProgress.java . upload.java makes applet GUI and
I have developed an applet java with Eclipse, which is included in MyPage.html. I
I'm trying to get to the bottom of a problem with our Java applet

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.