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 4125694
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T23:54:12+00:00 2026-05-20T23:54:12+00:00

I am in my first programming class and I am now reaching the end

  • 0

I am in my first programming class and I am now reaching the end of the semester. I have an online portfolio where I share my college accomplishments. At this point in the semester, I would like to upload some of the simple Applets I have created to my online portfolio. My portfolio is hosted on Weebly.com. I tried uploading the files to the host site and using the simple tags to run the applet within the html. I’m quite sure I’m accessing the files using the correct directories. But before we jump to any conclusions there, I decided I ought to run the applets locally to ensure I’m doing everything correctly. I am on a macbook pro running OS 10.6.6. In Java Preferences, my Java SE versions are Java SE 6 64-bit and Java SE 6 32-bit. My plug-in version is 1.6.0 (found in /System/Library/Java/JavaVirtualMachines). These are the only versions I have on my machine. My research tells me that I may be having version disagreements. Some forums have suggested going back to plug-in version 1.5 (although, I have no idea how). I’m pretty sure now though that apple has updated Safari to a 64-bit version. I have Eclipse set to 1.6 also. Everything seems to be on the same page to me.

And yes, I’ve read all the related questions on here over and over. Most of them are a little outdated now.

Here’s my applet code:

/** 
 * Class NightScene - Draws a night scene (just for fun). 
 *  
 * @author Alex Stout 
 * @version February 8, 2011 
 */ 
package lab05_1; 
import java.awt.*; 
import javax.swing.*; 

public class NightScene extends JApplet 
{ 
        /** 
         * Paint method for applet. 
         *  
         * @param  g   the Graphics object for this applet 
         */ 
        public void paint(Graphics g) 
        { 
            g.setColor(Color.BLUE.darker().darker().darker());
            g.fillRect(0,0, this.getWidth(), this.getHeight());

            this.drawMoon(g);

            this.drawStars(g);

            this.drawHorizon(g);

        }
        public void drawStars(Graphics h)
        {   
            for (int i = 0 ; i <= this.getWidth()*5; i++)
            {
                int x = (int)(Math.random()*this.getWidth());
                int y = (int)(Math.random()*this.getHeight());

                h.setColor(Color.WHITE);
                h.fillOval (x, y, (int) (Math.random()*3)+1, (int) (Math.random()*3)+1);
            }

        }
        public void drawMoon(Graphics j)
        {
            int x = (int)(Math.random()*(this.getWidth()-200)+50);
            int y = (int)(Math.random()*(this.getHeight()-200)+50);

            j.setColor(Color.YELLOW.brighter().brighter());
            j.fillOval (x, y, this.getWidth()/10, this.getWidth()/10);
            j.setColor (Color.BLUE.darker().darker().darker());
            j.fillOval (x-(this.getWidth()/100), y-(this.getWidth()/100), this.getWidth()/10, this.getWidth()/10);
        }   

        public void drawHorizon(Graphics k)
        {
            int xi = 0;
            int xj = this.getWidth();
            int yj = this.getHeight();
            int rh = this.getHeight()-this.getHeight()/8;

            for (int i=0; i < xj; i++)
            {
                k.setColor(Color.BLACK);
                k.drawLine(xi, yj, xi, rh);

                k.setColor(Color.BLUE);
                if(Math.random()<0.50)
                {
                    k.drawLine(xi++, rh++, xi, rh++);
                }
                else
                {
                    k.drawLine(xi++, rh--, xi, rh--);
                }

            }           
        }
}    

Here’s my html code:

<html>
<Applet code = NightScene.class codebase = "." width = "400" height = "400">
</Applet>
</html>

Here’s the Java Console output:

Java Plug-in 1.6.0_24
Using JRE version 1.6.0_24-b07-334-10M3326 Java HotSpot(TM) 64-Bit Server VM
User home directory = /Users/myUserName

Some people have suggested using codebase = “.” so I tried that to no avail. It doesn’t work with or without it. I tried putting in the full directory path, no success. I tried quotes and no quotes around the class name. I tried with and without .class on the end. I tried making a lab05_1 subdirectory because that’s the package name in the code. No luck. Both the class file and the html file are in the same folder on the desktop. The class file is a copy of the original one that was created in Eclipse, but it has the same name, so I wouldn’t think this should cause any problems being in different directories.

I don’t know what else to do. Please Help! This has been irking me for a week. I’ve spent hours upon hours on something so simple.

  • 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-20T23:54:13+00:00Added an answer on May 20, 2026 at 11:54 pm

    I don’t have a Mac handy to check this, but if you change your HTML file, it should work — you are missing the package name for the NightScene.class.

    <html>
      <Applet code="lab05_1.NightScene.class" width="400" height="400"/>
    </html>
    

    The Oracle reference for the APPLET tag is here.

    From that page:

    CODE = appletFile

    This REQUIRED
    attribute gives the name of the file
    that contains the applet’s compiled
    Applet subclass. This file is relative
    to the base URL of the applet. It
    cannot be absolute. One of CODE or
    OBJECT must be present. The value
    appletFile can be of the form
    classname.class or of the form
    packagename.classname.class.


    EDIT: Just in case it’s not clear, the directory should be laid out like so:

        +-top-level/
          |
          +-lab05_1/
          | |
          | +-NightScene.class
          |
          +-test.html
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First of all this is all just concept, I have no actual programming done
I'm a programming student, and I've now had two classes in C#, this semester
I'm a student in my first C++ programming class, and I'm working on a
I am just starting to learn Ruby (first time programming), and have a basic
I am taking a principals of programming class right now. We are learning about
I have to write a program for my C programming class that takes a
Strange programming problems as of now..As you can see below i have assigned intFrontPtr
I've been programming in Java for a little while now but have never really
This one has been puzzling my for some time now. Let's imagine a class
This is my first time programming and I'm struggling to understand what should be

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.