Programming help (applets in crimson editor)

  • Thread starter Thread starter fletchersally
  • Start date Start date
  • Tags Tags
    Programming
Click For Summary

Discussion Overview

The discussion revolves around troubleshooting a Java applet code in Crimson Editor, specifically addressing an error related to the absence of a main method. Participants explore the nature of the error and the requirements for running applets versus standalone applications.

Discussion Character

  • Technical explanation
  • Debate/contested

Main Points Raised

  • The original poster encounters a "NoSuchMethodError: main" when attempting to run their applet code.
  • Some participants suggest that the error indicates the code is being run as a standalone application rather than as an applet.
  • One participant notes that applets do not require a main method, but emphasizes the need to run the code in an appropriate environment that supports applets.
  • Another participant mentions switching to Notepad++ due to issues with Crimson Editor, implying potential limitations of the latter.
  • There is a discussion about code formatting and the importance of using code tags for clarity in forum posts.

Areas of Agreement / Disagreement

Participants generally agree that the error is related to how the code is being executed, but there is no consensus on the capabilities of Crimson Editor regarding applet execution. Some believe it cannot run applets directly, while others suggest alternative methods.

Contextual Notes

Limitations include uncertainty about the specific features of Crimson Editor and whether it can run applets directly. There is also a lack of clarity on the exact steps needed to create a web page for applet execution.

fletchersally
Messages
2
Reaction score
0
Completely new to this and having some trouble with the following code...

I'm trying to run this code in Crimson editor:
Code:
import java.awt.*; 
import javax.swing.JApplet; 

public class Snowman extends JApplet { 
    public void paint (Graphics g) { 
        final int MID = 150; 
        final int TOP = 50; 
        setBackground(Color.CYAN); 
        g.setColor(Color.BLUE); 
        g.fillRect(0, 175, 300, 50); 
        g.setColor(Color.YELLOW); 
        g.fillOval(-40, -40, 80, 80); 
        g.setColor(Color.WHITE); 
        g.fillOval(MID-20, TOP, 40, 40); 
        g.fillOval(MID-35, TOP+35, 70, 50); 
        g.fillOval(MID-50, TOP+80, 100, 60); 
        g.setColor(Color.BLACK); 
        g.fillOval(MID-10, TOP+10, 5, 5); 
        g.fillOval(MID+5, TOP+10, 5, 5); 
        g.drawArc(MID-10, TOP+20, 20, 10, 190, 160); 
        g.drawLine(MID-25, TOP+60, MID-50, TOP+40); 
        g.drawLine(MID+25, TOP+60, MID+55, TOP+60); 
        g.drawLine(MID-20, TOP+5, MID+20, TOP+5); 
        g.fillRect(MID-15, TOP-20, 30, 25); 
    }   
}

but keep getting this error:


---------- Capture Output ----------
> "C:\Program Files (x86)\Java\bin\java.exe" Snowman
java.lang.NoSuchMethodError: main
Exception in thread "main"
> Terminated with exit code 1.

and I have no idea why!

Any help is greatly appreciated!
Thanks in advance.
 
Last edited by a moderator:
Physics news on Phys.org
Latest stable release is already 6 years old, it is rather miracle it works at all. After fighting problems (unrelated to java macros) I switched to Notepad++.
 
fletchersally: Notice how I edited your post. Your code now looks like code. Use the code tags for code. You can either type them in manually or you can select a bunch of text and click on the code icon, the icon formed by a white box with its upper right corner torn off and with a # symbol inside.

Your code is also indented. There are number of different indentation schemes. Arguing which one is "right" starts religious wars amongst programmers. However, almost all programmers will agree that flush left is not "right".

java.lang.NoSuchMethodError: main
The error message is telling you that you don't have a main function. You need to have a main.
 
D H said:
The error message is telling you that you don't have a main function. You need to have a main.

You don't need a main() function in an applet. Your code looks OK (but I haven't tested it!)

What the error message really means is that you are trying to run your code as a stand-alone program, not as an applet.

Some Java development systems have a "run as applet" option that simulates the way an applet is meant to start running from inside a web page. (I don't know if the Crimson editor can do that, or how to do it). Otherwise, you will have to create a simple web page that displays the applet, and open the page in your web browser.
 
Thanks for that DH, still learning how to use this website also, and yes AlephZero I don't think Crimson can, so I'm using dos. Thanks!
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
5K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
5K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 19 ·
Replies
19
Views
2K