Cannot find class javax.swing.JOptionPane

Hello,
I imported the class
import javax.swing.JOptionPane;and written as a first line of my code in the form of a .java file.
but error occurs as : cannot find the class javax.swing.JOptionPane. What should I do.
Thank you.

Are you doing something likeimport javax.swing.JOptionPane;
class Test {
    public static void main(String args[]) {
        JOptionPane.showMessageDialog(null, "Testing",
                "Testing", JOptionPane.INFORMATION_MESSAGE);
}Mark

Similar Messages

  • Import javax.swing.JOptionPane

    hello
    i just installed j2sdk1.3.1 into my redhat linux7.3, during installation, everything's fine...
    but when i start to compile a program with some import classes...i face the problem :
    cannot find type "javax/swing/JOptionPane
    this is my program :
    import javax.swing.JOptionPane;
    public class Welcome{
    public static void main(String args[])
         JOptionPane.showMessageDialog(null,"Hello");
         System.exit(0);
    can anybody help me with this problem......?...thanks

    type
    java -versionto see which version of the JVM you are running
    you could also try
    which javato see the actuall executable that you are running.

  • Cannot Import javax.swing.JOptionPane   Please HELP!!!

    import javax.swing.JOptionPane;
    this line of code returns the error:
    C:\Java Files\BankAccount\BankAccount_Test.java:1: Class javax.swing.JOptionPane not found in import.
    import javax.swing.JOptionPane;
    ^
    1 error
    Process completed.
    Please help, I don't know what the problem could be....

    Swing was not part of any JDK's earlier than 1.2. Swing (or anything with a J in front of it, ie. JFrame, JOptionPane, etc...) was probably the most dramatic (if not largest) modification/addition to the Java language, that's why versions later than, and including, 1.2 are known as "Java 2".

  • Variable textArea not found in class javax.swing.JFrame...

    Making progress on this issue -- but still stuck. Again trying to get the text from a JTextArea on exit:
            frame.addWindowListener
           (new WindowAdapter() {
             public void windowClosing(WindowEvent e)
                System.out.println("Why me???" + frame.textArea.getText());
            });User MARSIAN helped me understand the scope fo the variables and now that has been fixed. Unfortunately I cannot access my variable textArea in the above code. If get this error:
    Error: variable textArea not found in class javax.swing.JFrame
    What am I doing wrong?
    import  java.net.*;
    import  javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import FragImpl.*;
    public class Framework extends WindowAdapter {
        public int numWindows = 0;
        private Point lastLocation = null;
        private int maxX = 500;
        private int maxY = 500;
        JFrame frame;
        public Framework() {
            newFrag();
            Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
            maxX = screenSize.width - 50;
            maxY = screenSize.height - 50;
            makeNewWindow();
        public void makeNewWindow() {
            frame = new MyFrame(this);  //*
            numWindows++;
            System.out.println("Number of windows: " + numWindows);
            if (lastLocation != null) {
                //Move the window over and down 40 pixels.
                lastLocation.translate(40, 40);
                if ((lastLocation.x > maxX) || (lastLocation.y > maxY)) {
                    lastLocation.setLocation(0, 0);
                frame.setLocation(lastLocation);
            } else {
                lastLocation = frame.getLocation();
            System.out.println("Frame location: " + lastLocation);
            frame.setVisible(true);
            frame.addWindowListener
           (new WindowAdapter() {
             public void windowClosing(WindowEvent e)
                System.out.println("Why me???" + frame.textArea.getText());
        //This method must be evoked from the event-dispatching thread.
        public void quit(JFrame frame) {
            if (quitConfirmed(frame)) {
                System.exit(0);
            System.out.println("Quit operation not confirmed; staying alive.");
        private boolean quitConfirmed(JFrame frame) {
            String s1 = "Quit";
            String s2 = "Cancel";
            Object[] options = {s1, s2};
            int n = JOptionPane.showOptionDialog(frame,
                    "Windows are still open.\nDo you really want to quit?",
                    "Quit Confirmation",
                    JOptionPane.YES_NO_OPTION,
                    JOptionPane.QUESTION_MESSAGE,
                    null,
                    options,
                    s1);
            if (n == JOptionPane.YES_OPTION) {
                return true;
            } else {
                return false;
         private void newFrag()
              Frag frag = new FragImpl();
        public static void main(String[] args) {
            Framework framework = new Framework();
    class MyFrame extends JFrame {
        protected Dimension defaultSize = new Dimension(200, 200);
        protected Framework framework = null;
        private Color color = Color.yellow;
        private Container c;
        JTextArea textArea;
        public MyFrame(Framework controller) {
            super("New Frame");
            framework = controller;
            setDefaultCloseOperation(DISPOSE_ON_CLOSE);
            setSize(defaultSize);
            //Create a text area.
            textArea = new JTextArea(
                    "This is an editable JTextArea " +
                    "that has been initialized with the setText method. " +
                    "A text area is a \"plain\" text component, " +
                    "which means that although it can display text " +
                    "in any font, all of the text is in the same font."
            textArea.setFont(new Font("Serif", Font.ITALIC, 16));
            textArea.setLineWrap(true);
            textArea.setWrapStyleWord(true);
            textArea.setBackground ( Color.yellow );
            JScrollPane areaScrollPane = new JScrollPane(textArea);
            //Create the status area.
            JPanel statusPane = new JPanel(new GridLayout(1, 1));
            ImageIcon icoOpen = null;
            URL url = null;
            try
                icoOpen = new ImageIcon("post_it0a.gif"); //("doc04d.gif");
            catch(Exception ex)
                ex.printStackTrace();
                System.exit(1);
            setIconImage(icoOpen.getImage());
            c = getContentPane();
            c.setBackground ( Color.yellow );
            c.add ( areaScrollPane, BorderLayout.CENTER )  ;
            c.add ( statusPane, BorderLayout.SOUTH );
            c.repaint ();
    }

    Yeah!!! It works. Turned out to be a combination of DrKlap's and Martisan's suggestions -- had to change var frame's declaration from JFrame to MyFrame:
        MyFrame frame;Next, created the external class -- but again changed JFrame references to MyFrame:
    public class ShowOnExit extends WindowAdapter {
    //   JFrame aFrame;
       MyFrame aFrame;
       public ShowOnExit(MyFrame f) {
          aFrame = f;
       public void windowClosing(WindowEvent e)
          System.out.println("Why me???" + aFrame.textArea.getText()); // aFrame here not frame !!!
    }This worked. So looks like even though the original code added a WindowListener to 'frame', the listener didn't couldn't access frame's methods unless it was explicitly passed in as a parameter. Let me know if that's wrong.
    Thanks again, all.

  • Cannot find class JPanel

    Hi,
    Im trying to use swing for almost the first time.
    I changed my system to Linux and installed J2sdk 1.4.
    When I write a class
    e.g.
    import javax.swing.*;
    import java.awt.*;
    etc...
    class Test extends JPanel {
    I receive an error message "Cannot find class "JPanel""
    Can anyone help ? Maybe I didnt install the right thing ?
    Thanks
    Ulrike

    you sure reinstall and overwrite your current sdk. Do you have the runtime environment installed too -- should come with the sdk

  • Preverification error: Cannot find class com/sun/perseus/model/Viewport

    Hi all,
    I have a (previously) working Midlet to which I have added one line as follows:
    SVGImage image = (SVGImage)SVGImage.createEmptyImage(null);
    - and imported the necessary from javax.microedition.m2g. (I am using the library that comes with the WTK, jsr226.jar).
    This builds, jars, obfuscates fine. But when I try to preverify (using Antenna's wtkpreverify) on the jar, it gives up in disgust very swiftly as follows:
    [wtkpreverify] Error preverifying class javax.microedition.m2g.ScalableGraphics
    [wtkpreverify] VERIFIER ERROR javax/microedition/m2g/ScalableGraphics.render(IILjavax/microedition/m2g/ScalableImage;)V:
    [wtkpreverify] Cannot find class com/sun/perseus/model/Viewport
    I'm using the WTK2.5.1ea and antenna 0.9.14, CLDC1.1, MIDP2.0...
    Many thanks for any ideas.

    Problem resolved simply by replacing jsr226.jar (as distributed with WTK2.5.1ea) with m2g.jar (as distributed with J2MEPolish).

  • Cannot access class javax.naming.Referenceable;

    Hi
    I am trying to create a connection pool and using the oracle.jdbc.pool.* in JavaBeans using JDeveloper 3.1.
    I am getting the following error.Unable to find the reason for this and the sun documentation says - no usage for this class.
    Error:
    cannot access class javax.naming.Referenceable; file javax/naming/Referenceable.class not found.
    Any help is greatly appreciated..
    thanks
    Yugandhar
    null

    You need to make sure $ORACLE_HOME/jdbc/lib/jndi.zip is on your classpath for this to work.

  • Cannot access class javax.jms.TextMessage;

    Hi,
    I am trying to run standard page from JDev and i am getting below error from EOImpl.java.
    " cannot access class javax.jms.TextMessage; file javax\jms\TextMessage.class not found "
    I tried to import javax/jms dir to my local machine but i could not find jms directory under javax in OS. Can you guys pls help me to resolve this.
    Thanks,

    Hi Scott,
    Not sure wht you wanted me to try...
    I have something like this in the code which is causing that error..
    BusinessEvent businessevent = new BusinessEvent(s1, s2);
    businessevent.setData("Opportunity " + s2 + "updated");
    ArrayList arraylist = new ArrayList(1);
    arraylist.add(oadbtransaction);
    businessevent.setObject(arraylist);
    businessevent.setStringProperty("pLeadId", getLeadId().toString());
    java.sql.Connection connection1 = oadbtransaction.getJdbcConnection();
    businessevent.raise(connection1);
    Its asking me to import jms..but ii could not find those files in Unix..is there anyway to import these files OR any other solution to fix this error?
    Please help..

  • Cannot access class javax.sql.RowSet

    Hello everyone,
    I had a question about this error I am receiving "cannot access class.javax.sql.RowSet". I have put the RowSet.jar file into my jdk/jre/lib/ext directory and when I compile I recieve this error. Can Anyone help? Thanks!

    I think you need to add one (or more) of the available libraries to your project, in your project's settings dialog, but I'm unsure which. If you can't find the correct one, you can always add a newly created one, which holds a reference to your jar file.

  • Cannot find class: Exception??

    Hi
    The compiler claims it cannot find class FileNotFoundException or any other exception in my Main. Any packages I import has no problem. My structure:
    java \ myMain \ Main.java
    java \ com \ myName \ packages //no, the space is just there as visual help:)
    Use javac -classpath java\ @compile.file
    ...where compile.file is a txt file giving the paths and filenames to all files I include.
    This is first time I use the -classpath parameter, but I believed java.lang always was included. What Am I doing wrong.
    regards
    JT

    You should review the tool documentation for the javac command and its use of classpath.
    Your problem appears to be due to the way you defined classpath, "-classpath java\". While you don't provide enough information to conclusively say what it should be, I'm guessing it should also include java\myMain\ - assuming that you're issuing the javac command from the parent of the \java\ directory, as your command example indicates.
    Here is a clip about its use of the classpath.
    "When compiling a source file, the compiler often needs information about a type whose definition did not appear in the source files given on the command line. The compiler needs type information for every class or interface used, extended, or implemented in the source file. This includes classes and interfaces not explicitly mentioned in the source file but which provide information through inheritance.
    For example, when you subclass java.applet.Applet, you are also using Applet's ancestor classes: java.awt.Panel, java.awt.Container, java.awt.Component, and java.lang.Object.
    When the compiler needs type information, it looks for a source file or class file which defines the type. The compiler searches for class files first in the bootstrap and extension classes, then in the user class path (which by default is the current directory). The user class path is defined by setting the CLASSPATH environment variable or by using the -classpath command line option. (For details, see Setting the Class Path).
    If you set the -sourcepath option, the compiler searches the indicated path for source files; otherwise the compiler searches the user class path for both class files and source files."

  • Cannot find class java/lang/Thread

    I'm getting this error trying to compile a program that I'm writing in java. Its a very simple program just to get me back to basics. Any ideas as to how I can fix this problem??

    Extracted from Sun's website,
    * Error Message: "Exception in thread NULL" or
    "Unable to initialize threads: cannot find class java/lang/Thread"
    If you are getting one of these fatal error messages when running java,
    javac, or appetviewer, you should check your CLASSPATH environment variable.
    It may list "c:\java" or the "classes" directory from an older release. You can either unset the CLASSPATH variable, or set it to
    include only the latest version of the Java platform class library. For example:
    C:\> set CLASSPATH=.;C:\jdk1.1.8\lib\classes.zip
    This will make sure that you are using the correct classes for this release.
    -- Sudha

  • Cannot find class "Hello"

    Hi,
    I'm developing a application for a windows ce v.2.11, and I've installed in my PDA (MIPS) Personal Java. The samples of Personal Java run perfectly. I've create a simple new class (Hello.class) with Sun One Studio, then I copy this file (Hello.class) in my pda, and when I run the application I saw this messages: "Cannot find class Hello".
    Anybody can explain me step by step the correct way to create a new class or a new jre to run in my PDA?
    Another question: Where are installed the classes as AWT?
    Thanks

    Please see my reply to your latest post.

  • Javax.swing.JOptionPane

    im a new programmer and i just downloaded ready to program with java and i need to import javax.swing.JOptionPane but it says it dosnt exists where can i go to get it ?
    ty for your help in advance.

    im using READY TO PROGRAM with java i unno what jdk that is sorry but umm here is the error meassage when i try to compile it.
    javax/swing/JOptionPane is either a misplaced package name or a non-existent entity. When i use this exact code at my schools computers it seems to work fine. so i unno ty for your help all

  • Jdeveloper - Could not initialize class javax.swing.KeyStroke

    I am trying to install jdeveloper on a new machine, I have installed latest JDK from sun and downloaded the jdevstudiobase101033.zip file, however once I have followed the instructions to install on linux (Fedora core 11 - 64bit) and try to fire jdev up using jdev/bin/jdev I get the following error message:
    Oracle JDeveloper 10g 10.1.3.3
    Copyright 1997, 2007 Oracle. All Rights Reserved
    java.lang.NoClassDefFoundError: Could not initialize class javax.swing.KeyStroke
         at java.lang.Class.forName0(Native Method)
         at java.lang.Class.forName(Class.java:169)
         at oracle.ide.IdeCore.class$(IdeCore.java:98)
         at oracle.ide.IdeCore.startupImpl(IdeCore.java:816)
         at oracle.ide.Ide.startup(Ide.java:674)
         at oracle.ideimpl.Main.start(Main.java:49)
         at oracle.ideimpl.Main.main(Main.java:25)
    I have trawled through google and forums at oracle with no joy, could someone kindly give me some pointers as to what I have missed or what may be wrong ?
    Thanks
    Ian

    It is running the 32 bit JDK, the 64 bit threw up errors even earlier in the startup porcedure.
    Ian

  • Error:Cannot find class

    Hi
    I compile my application correctly, but when I copy this application in my PDA, and run this application (Hello.class) with Personal Java I saw a this message: Cannot find class Hello.class.
    I don't compile javacheck before copy in my PDA the application.
    Please help me

    Hi,
    are you sure that your classpath is set correct?
    For checking this you'll need a registry editor and check the command that is entered for the .class file extensions.
    Have a nice day,
    FReAK

Maybe you are looking for

  • Report needed containing dependent/beneficiary info

    Hi Gurus, Is there a standard report where I could pull in dependent/beneficiary names, SSN and Date of Birth? Please advise

  • SOAP: addparameter - Fields and Tags in generated document

    Hi all, I am trying to call a webservice using the soapincl. everything works fine until I need to send a structure: I defined a structure: targetid with one field x. GET REFERENCE OF targetid INTO dref.   CALL METHOD osoap->add_parameter            

  • Doubt in prms

    Hi experts,           I am created one classical report with selection option, the selection option have ranges, if i give the range ( My data are very very huge ) its giving dump error of Times out.. so how to rectify the error.. urgent.. Gowri

  • Need info for Implementing Service Analytics

    Hi , My clicnet is planing to implementing service analytics, i would like to know the procedure is that where to start what to needs to be install. We are going to use sibel applications and what are the things to taken care while installing a BI Ap

  • Forms Runtime for different applications

    Hello, I am running 3 applications on Windows XP. When I try to use Forms builder to run some of the Forms in these applications it works for only one of the applications the other two applications do not work. When I run a Form in the other 2 applic