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);
}
}
}

Applets are not started from the command line like a regular java program. You need to use the Java Applet Viewer or embed them in a small test web page. If you typed this program from a book then there are probably instructions there on how to run the applet. If not, read the following tutorial on getting started with applets:
http://java.sun.com/docs/books/tutorial/deployment/applet/index.html

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.