Hot questions for Using Applets in netbeans


How can I debug or run a class that extends java.applet.Applet? I am able to run the applet from the command line with appletviewer.

appletviewer runapp.html

Here is what class looks like:

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

public class FancyApplet extends Applet {
    public void paint(Graphics g) {
        g.drawString("Hello World!", 20, 20);

Here is what the HTML file looks like

<!doctype html>

    <meta charset="utf-8">
    <title>A Fancy Applet</title>

<object type="application/java" width="200" height="300">
    <param name="code" value="FancyApplet.class">

How do I have to organize those files within my project and what settings do I have to use to debug the Applet in NetBeans? The thread Running a java applet from netbeans? did not help unfortunately. I did what was suggested, but get a message telling me that the main class was not found. What I took from it though was that in my case the HTML file is not even needed? But just because I am curious is it still possible or recommended to use it?


As you don't have public static void main(String[] args) in your FancyApplet class, so the above error is produced.

You can run your java applet in the NetBeans IDE by pressing Shift + F6 key from your main class(keeping cursor inside FancyApplet class here). It'll run the applet program without searching for the main method.

This is an alternate shortcut method of running individual classes in NetBeans IDE.


I am trying to run my applet in netbeans IDE But browser is not opening automatically. If I copy address to browser it is running. Project runs in localhost.

Error is as follows---

  java.util.MissingResourceException: Can't find resource for bundle    
  org.openide.util.NbBundle$PBundle, key MSG_win_browser_invocation_failed
at java.util.ResourceBundle.getObject(
at java.util.ResourceBundle.getString(
at org.openide.util.NbBundle.getMessage(
at org.netbeans.modules.extbrowser.NbDdeBrowserImpl$

  [catch] at


Sounds like a known issue in the Netbeans.

It has a lots of dulicates over different versions, looks like they fixed in the nightly build, but it is still not released.


I am trying to build a very simple program with java applet.

The program should navigate to corresponding website as an user click on their links which are appearing on the applet window.

But in my case no applet window is popping up! Well there is a window popping up (below is the image) (as soon as I run the code) which is not the relevant with my program.


    package stringpractice;

import java.awt.*;
import java.applet.*;
import javax.swing.*;
import javax.swing.event.*;
import java.util.*;
import javax.swing.plaf.basic.BasicListUI;

public class Applet extends JApplet {
    private HashMap<String,URL>websiteInfo;
    private ArrayList<String>titles;
    private JList mainList;

    private void inIt(){
        websiteInfo =new HashMap<String, URL>();
        titles =new ArrayList<String>();

        add(new JLabel("What website u wanna visit?"),BorderLayout.NORTH);
        mainList=new JList(titles.toArray());


        new ListSelectionListener() {

            public void valueChanged(ListSelectionEvent event) {

                Object object = mainList.getSelectedValue();
                URL newDocument = websiteInfo.get(object);
                AppletContext browser = getAppletContext();

        add(new JScrollPane(mainList),BorderLayout.CENTER);

    private void grabHTMLInfo(){
        String title;
        String address;
        int counter=0;
        URL url;
            try {
                url =new URL(address);
                websiteInfo.put(title, url);
            } catch (MalformedURLException uRLException) {




.java main:

package stringpractice;

public class appletMain {

    public static void main(String[] args) {




<title>testing applet</title>


<applet code="Applet.class" width="500" height="200">

<param name="title0" value="Google">
<param name="address0" value="">

<param name="title1" value="Yahoo">
<param name="address1" value="">





Your init() method is written as inIt(). As everything is case sensitive, your init method gets never called.


Why the program search the file:

    File FILE_PATH = new File("‪‪C:\\Users\\home\\Desktop\\DbWord.txt");
    FileInputStream fIn = new FileInputStream(FILE_PATH);
    Scanner reader = new Scanner(fIn);

at: C:\Users\home\Documents\NetBeansProjects\MyDatabase\‪‪C:\Users\home\Desktop\DbWord.txt

How can i counteract the default location?

If something in this post not good, please tell me and no negative vote.


why negative votes??????????????? whats your problems??????????


Please double check your error details. You might have seen something like the below error. Actually the program is not searching for the file "C:\Users\home\Documents\NetBeansProjects\MyDatabase\‪‪C:\Users\home\Desktop\DbWord.txt", it is trying to locate the file "C:\Users\home\Desktop\DbWord.txt" which does not exists in your machine. You are seeing "C:\Users\home\Documents\NetBeansProjects\MyDatabase\‪‪C:\Users\home\Desktop\DbWord.txt" along with the error because you have already used System.out.println(FILE_PATH.getAbsoluteFile()); statement in your code.

Exception in thread "main" ‪‪C:\Users\home\Desktop\DbWord.txt (The filename, directory name, or volume label syntax is incorrect)
    at Method)
    at com.stackoverflow.answer.SimpleFileHelper.main(

Hope you are clear now.

There are three main chances where a FileNotFoundException may be thrown.

  1. The named file does not exist.
  2. The named file is actually a directory not file.
  3. The named file cannot be opened for reading due to some reason.

The first two reasons are unlikely based on your description, please check the third point using file.canRead() method.

If the test above returns true, I would suspect the following:

You might have forgotten to explicitly throw or catch the potential exception (i.e., FileNotFoundExcetion). If you work in an IDE, you should have got some complaint from the compiler. But I suspect you didn't run your code in such an IDE.

Try the following code and see if the exception would be gone:

package com.stackoverflow.answer;

import java.util.Scanner;

public class SimpleFileHelper {

    public static void main(String[] args) throws FileNotFoundException {
        File FILE_PATH = new File("C:/Users/home/Desktop/DbWord.txt");
        FileInputStream fIn = new FileInputStream(FILE_PATH);
        Scanner reader = new Scanner(fIn);