Solved

simple question

Posted on 2004-09-14
5
166 Views
Last Modified: 2013-11-23
sir ,

 i mworking on mandrake linux on a
p3 system.


 i wrote a program for a creating a standalone window .That is it contains a main.

When i compile with javac , no error.
But when i try to run it using javac .Following errors



at java.lang.Class.for Name(class .java:native)

at java.lang.Class.for Name
(class:59)


what is this ? how can iavoid this ?
how can i create standalone window in java on linux platform ?


 
0
Comment
Question by:karana
5 Comments
 
LVL 21

Expert Comment

by:MogalManic
ID: 12061129
Is your classpath set correctly?
0
 
LVL 1

Expert Comment

by:raid999
ID: 12061332
Try this

import java.applet.*;
import java.awt.*;
import java.awt.event.*;
/** An applet that can also run as a standalone application */
public class StandaloneScribble extends Applet {
  /**
   * The main() method.  If this program is invoked as an application,
   * this method will create the necessary window, add the applet to it,

   
   * and call init(), below.  Note that Frame uses a PanelLayout by
   * default.              
   */
  public static void main(String[] args) {
    Frame f = new Frame();                     // Create a window
    Applet a = new StandaloneScribble();       // Create the applet panel
    f.add(a, "Center");                        // Add applet to window
    a.init();                                  // Initialize the applet
    f.setSize(400, 400);                       // Set the size of the
                                               // window
    f.show();                                  // Make the window visible
    f.addWindowListener(new WindowAdapter() {  // Handle window close
                                               // requests
      public void windowClosing(WindowEvent e) { System.exit(0); }
    });
  }
  /**
   * The init() method.  If the program is invoked as an applet, the
   * browser allocates screen space for it and calls this method to set
   * things up.
   */
  public void init() {
    // Define, instantiate and register a MouseListener object
    this.addMouseListener(new MouseAdapter() {
      public void mousePressed(MouseEvent e) {
        lastx = e.getX();
        lasty = e.getY();
      }
    });
    // Define, instantiate and register a MouseMotionListener object
    this.addMouseMotionListener(new MouseMotionAdapter() {
      public void mouseDragged(MouseEvent e) {
        Graphics g = getGraphics();
        int x = e.getX(), y = e.getY();
        g.setColor(Color.black);
        g.drawLine(lastx, lasty, x, y);
        lastx = x; lasty = y;
      }
    });
    // Create a clear button
    Button b = new Button("Clear");
    // Define, instantiate, and register a listener to handle button
    // presses
    b.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {  // clear the scribble
        Graphics g = getGraphics();
        g.setColor(getBackground());
        g.fillRect(0, 0, getSize().width, getSize().height);
      }
    });

    // And add the button to the applet
    this.add(b);
  }
  protected int lastx, lasty;  // Coordinates of last mouse click
}


$tigger javac StandaloneScribble.java

$tigger java StandaloneScribble
0
 

Author Comment

by:karana
ID: 12066315
i got it sir ,

 i dont know how it worked , but doing trial and error ,


 i added this line

 import java.lang. * ;

0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 12319474
PAQed, with points refunded (50)

Computer101
E-E Admin
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question