Hi,

I have this Java code not running properly with showing the following error at command prompt on Linux os.

[root@localhost PracJava]# javac clicker.java
[root@localhost PracJava]# java clicker
Exception in thread "main" java.lang.NoSuchMethodError: main

Can any one help please? Thanks.....

import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
 
public class clicker extends Applet implements ActionListener
{
TextField text1;
Button button1;
 
public void init()
{
text1 = new TextField(20);
add(text1);
button1 = new Button("Click here!");
add(button1);
button1.addActionListener(this);
}
 
public void actionPerformed(ActionEvent event)
{
String msg=new String ("Welcome to Java");
if(event.getSource()==button1)
{
text1.setText(msg);
}
}
}

Applet requires appletviewer to execute its code.
Pls find the utility by name appletviewer in the java installed utility directory u wil find the exe for running the applet.

Applet requires appletviewer to execute its code.
Pls find the utility by name appletviewer in the java installed utility directory u wil find the exe for running the applet.

Hi,

Thanks.

Can you please tell me as how I can find the instructions in the installed directory on Linux. I am on Fedora core 5 32+ bit as my OS. I am new to Java and need some help. I have also tried to run a few basic applets in Firefox but it only shows a grey box and says download the required plug in etc. I am getting a bit confused here please help me out with this. Thanks for your time and patience. Cheers.

You need to install Java plugin for Firefox. Here's what you are required to do:

sudo ln -s /usr/lib/jvm/jre1.6.0_01/plugin/i386/ns7/libjavaplugin_oji.so /usr/lib/firefox/plugins/libjavaplugin_oji.so

i.e., you are creating a symbolic linc (short cut in Windows) to the libjavaplugin_oji.so file which firefox can use.

If in fedora, you do not have "sudo", then use "su" instead. Also, find the path where jre is installed on your system.

On my system it is installed in /usr/lib/jvm/jre1.6.0_01/ directory

This article has been dead for over six months. Start a new discussion instead.