Import javax.swing.* error

Heya. I decided to learn java and i've been doing the tutorials, recently i started the swing tutorials and the learn by example page. However, whenever I try to import javax.swing.* it gives me an error. SO you know, i am using the J2SDK 1.4.2 and netbeans IDE 5.0. Here's the error text and what i type.
import javax.swing.* ;
the error is:
illegal start of expression and then sometimes i get <identifier> expected.
can anyone help me?

To update. I figured out how to do this with a blank start file in netbeans, however it's awful to have to delete main and then make a new class file. So, is there anyway to get a blank template project or to import javax.swing.* without having to delete main and start with a blank file? SO, i guess my question has changed, but it's still about an import javax.swing.* error.
thanks.

Similar Messages

  • 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".

  • Importing javax.swing

    Im getting error while running script..
    The message :
    $ javac tablePane.java
    tablePane.java:3: Package javax.swing not found in import.
    import javax.swing.*;
    ^
    1 error
    $
    Can i have solution for this?
    Pani.G

    I am using metrowerks and i get the same problem with
    similiar code. I have J2sdk 1.4
    what do you think is wrong?I don't have worked with Metrowerks before, so are you sure that the compiler doesn't have an own
    JDK embedded (like JBuilder) ?
    If this is the case, I don't know if you can select in Metrowerks an other installed JDK.
    With kind regards
    F.-M. Jaeschke

  • Import javax.swing.*;

    I start my programm with:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import rechenwerk.Rechenwerk; import rechenwerk.RechenwerkFassade;
    import zahl.Zahl; import zahl.ZahlFassade;
    import oberflaeche.Oberflaeche;
    At "import javax.swing.*" i get the failure message from the compiler:
    Oktalrechner.java:8: Package javax.swing not found in import.
    import javax.swing.*;
    What is wrong? I don't know-please help me.
    I'm using JDK1.2BETA4

    Tell me when you execute java -version, what you are getting?
    Looks like you are suing old JDK.
    Download the latest public release JDK1.4 from http://java.sun.com
    /Sreenivasa Kumar Majji.
    Did somebody help you? I have a similar problem with
    javax.resource... :(
    I start my programm with:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import rechenwerk.Rechenwerk; import
    rechenwerk.RechenwerkFassade;
    import zahl.Zahl; import zahl.ZahlFassade;
    import oberflaeche.Oberflaeche;
    At "import javax.swing.*" i get the failure message
    from the compiler:
    Oktalrechner.java:8: Package javax.swing not foundin
    import.
    import javax.swing.*;
    What is wrong? I don't know-please help me.
    I'm using JDK1.2BETA4

  • 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.

  • Can't use import javax.swing.RowFilter; in javafx

    Dear all,
    I'm a question for you.
    I developed a javafx application in which I use also swing dialog and swingx libraries.
    The question is I can't use jtable filter of java jdf 1.6
    That is when I try to add in my netbeans javafx project
    import javax.swing.RowFilter;
    it says me it's not correct library
    If I create a java swing application I can add this include.
    Why it?
    I edited netbeans conf to set javafx sdk to javafx lib I downloaded (whole sdk), not that one with netbeans, but nothing.
    It seems like I can't use this import in javafx application.
    Is it posbbile?
    Please help me

    The reason you cannot use it is because javax.swing.RowFilter was introduced in Java 1.6 . Netbeans compiles JavaFX to work with Java 1.5, which does not have the class in question.
    I have gotten around this by going to the properties->Libraries->Add JAR/Folder menu and included the jre/lib/rt.jar file from the jre directly into my project.
    Someone else posted a similar solution and more detailed explanation here: http://steveonjava.com/hacking-javafx-10-to-use-java-16-features/

  • Importing  javax.swing.plaf.basic.BasicListUI.MouseInputHandler

    Hi!!
    I have totally no idea why I cannot import javax.swing.plaf.basic.BasicListUI.MouseInputHandler. The compiler says BasicListUI interface is expected.

    Agreed (maybe even so for 1.4.1 that I've just wiped out so I can't cehck my old rt.jar :o).
    For the moment I use my old translation of the basic.properties (and windods.properties) packed in a jar-file placed in
    jreXX/lib/ext/myLanguage.jar
    So far it works for the dialogs in my applications ...
    However, I don't find this a clean solution. I now find basic.class in rt.jar. Juged from all the other basic_xx.class files in rt.jar I guess this is where basic.properties went ... My next move will be to get hands on the source code of JAVA and check out how basic.java looks like ... perhaps this is a class filled with static fields and a simple method that sets properties in memeory or ? or ? ... In particular I need find out if some 'fields' have been added or removed compared to the old basic.properties. If so, the old translation would only be parial and my apps would be a mix of danish and english.
    I'm not really that much of a JAVA programmer and this is just to share some thoughts. Does anyone out there know a central reference on how those of us that speak minority languges easily get translations of core JAVA stuff (meaning Yes, No, Cancel and the like) take effect the easy way? Are there national boards that take care of such business?
    Maybe I haven't searched enough for information - my apologies if you found it waste of time reading this reply.
    With kind regards and thanks in advance, MJTJ

  • Import javax.swing problems

    hey
    I am new to java and have recently downloaded j2sdk1.4.2_04. I am trying to create a simple graphical application. However, It doesnt seem to import the javax.swing.* libraries. I understand that there is the src.zip in the directory, so I unzipped it but it still doesn't read the package. I read elsewhere on this forum that you should set the path to src.zip. I have tried that and it also doesnt work. My current path is:
    PATH=C:\j2sdk1.4.2_04\lib\src.zip;C:\j2sdk1.4.2_04\bin
    Is there an error in this, or what else should I try? All suggestions greatly appreciated.

    There's no need to set your classpath when importing any of the standard packages that are provided by the JDK. Perhaps you could post a (small) code sample and the compiler error you are getting.

  • Java Performance. Importing javax.swing.*

    Hi everyone,
    I have heard several times that importing entire packages into an application (class) that only requires 1-2 classes from that package is a bad idea, most notably for performance reasons (as well as code engineering quality).
    I'm wondering if someone can provide a concise and insightful reasons as to why this is the case. I'm currently moving a C++ application to Java (don't ask why!) and am looking at performance aspects.
    Thanks

    import statements tell the compiler where to look for the classes
    so it is not a performance issue when the program is executing.
    Also at compile time, the difference is insignificant compared to the
    rest of the compilation.
    As for code maintenance, I find that if I am using something from the
    java.util package, then I specifically import it, like import
    java.util.Vector. However, I genenerally import java.awt.event.*; and
    javax.swing.* because it is easier.
    I would worry about the architecture of your code more than import
    statements!!

  • Import javax.ejb errors when compiling

    Hi,
    when I am compiling my EJBs, (I am using Eclipse 2.1.1 , but I got the same thing using Bluej) I am getting errors that point to my import statements such as:
    import javax.ejb.SessionBean;
    do I need to install some jar files anywhere and configure my classpath? in order to be able to use EJBs?
    many thanks
    yan

    thanks,
    I already have j2ee installed and I have the j2ee.jar file in my classpath
    I was wondering if it was something more specific than this
    yan

  • Package javax.swing.event not found in import.

    I'm receiving the above error message when compiling a Java application which begins with the following import statements:
    * 1.1+Swing version.
    import javax.swing.*;
    import javax.swing.event.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    My Classpath System variables are as follows:
    C:\IBMCON~1\CICS\Classes\CTGCLI~1.JAR;.;C:\PROGRA~1\MQSeries\java\lib\COMIBM~2.JAR;C:\PROGRA~1\MQSeries\java\lib\COMIBM~1.JAR;C:\PROGRA~1\MQSeries\java\lib\COMIBM~3.JAR;C:\PROGRA~1\MQSeries\tools\javaclnt\samples\en_us;C:\Program Files\SQLLIB\java\db2java.zip;C:\Program Files\SQLLIB\java\runtime.zip;C:\Program Files\SQLLIB\bin;C:\Program Files\SQLLIB\java\SQLj.zip
    I have Java(TM) 2 SDK, Standard Edition, Version 1.4.0 installed and am running Windows 2000.
    I'd appreciate any ideas as to why this compiler error occurs. Thanks very much.

    What error message?
    As stated, looks like something's not where it's supposed to be.
    Here's the search order of your classpath:
    C:\IBMCON~1\CICS\Classes\CTGCLI~1.JAR
    C:\PROGRA~1\MQSeries\java\lib\COMIBM~2.JAR
    C:\PROGRA~1\MQSeries\java\lib\COMIBM~1.JAR
    C:\PROGRA~1\MQSeries\java\lib\COMIBM~3.JAR
    C:\PROGRA~1\MQSeries\tools\javaclnt\samples\en_us
    C:\Program Files\SQLLIB\java\db2java.zip
    C:\Program Files\SQLLIB\java\runtime.zip
    C:\Program Files\SQLLIB\bin
    C:\Program Files\SQLLIB\java\SQLj.zip

  • Import javax.servlet.* gives error "package does not exist"

    I am working through Monica Pawlan's book "Essentials of Java PL".
    My PC runs Windows2000 prof. I have downloaded and installed j2sdk-1_3_1_01-win.exe in c:\jdk1.3.1_01
    I have downloaded and installed tomcat4.0 (jakarta-tomcat-4.0.zip) into c:\jakarta-tomcat-4.0
    CATALINA_HOME is set to c:\jakarta-tomcat-4.0 and CLASSPATH is set to .;C:\jakarta-tomcat-4.0\common\lib\servlet.jar
    I can compile an applet starting:
    import java.awt.Color;
    import java.awt.BorderLayout;
    import java.awt.event.*;
    import javax.swing.*;
    //Class Declaration
    class SwingUI extends JFrame implements ActionListener { ... }
    but trying to compile my servlet starting:
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class ExampServlet extends HttpServlet { ... }
    gives me the error (import javax.servlet.*) "package does not exist".
    Any pointers on this immediate problem? and is my book out of date?
    Many thanks,
    James Towell

    You downloaded the Java 2 SDK Standard Edition, but you need to also download the Enterprise Edition if you want to write programs that use enterprise features.

  • Error "javax.swing.JFrame"  cannot find symbol  frame.getContentPane90.add

    Getting above errror when running the code below.how do I install the Jframe so the program can see it.Looks like JRE and JDK does not have it.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class SimpleGui1{
    public static void main(String []args){
    JFrame frame = new JFrame();
    JButton button = new JButton("click me");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane90.add(button);
    frame.setSize(300,300);
    frame.setVisible(true);
    }

    This is the single most amazing thread I have ever+* seen.                                                                                                                                                                                                   

  • 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

  • Getting started with import javax

    I'm working my way through tutorials re java 1.2, on linux.
    I have had no problem (so far) with code using import java.text.*; import java.util.*; etc But at import javax.swing.*; trying to work with JFrame, I get error - Package javax.swing not found in import.
    I'm a bit lost as none of the text seems to anticipate such a problem. Can anyone help.
    Thanks Richard

    it sounds like you are using an older version of java that does not yet support swing swing is new to to java since the java 2 platform. maybe you don't have that version on your computer of you are compiling with an older version try checking your verseion ( sorry i keep forgetting the numbers in wich the released swing)..

Maybe you are looking for

  • Is there a way to view logs of what has been happening to my iPhone 4S re: sim cards?

    My phone was basically stolen by a taxi driver--until I went to every effort to track him down--and my sim was removed. When I eventually found him 4 days later, he was very apologetic and full of excuses for why he didn't take it to the police stati

  • Acrobat Pro 11.0.9 print problem with Yosemite OS X 10.10

    I can no longer print 2d barcodes generated by USPS Click-and Ship website after upgrading to Yosemite 10.10.  The PDF on my display shows the 2d barcode, but when sending it to either a Brother printer or an HP printer, the word "Button" appears ins

  • DVD Build and burn

    Hello, I'm getting an error message "Power Calibration error, (0x73, 0x3) when a attempt a build and burn. Can anyone help? Thanx, John

  • Intercompany Implementation Options (in Projects) vs GIS

    Our company is project based and we utilize the intercompany billing between OUs. We've defined our Provider and Receivers in our Project module Implementation Options. We don't import any other non-Oracle intercompany transactions via interfaces. We

  • Moving-Intergrating CCM/Unity 3.X cluster to 4.2 cluster

    We are working on incorporating or upgrading a 3.2 cluster to 4.2. for CCM and Unity. Can we BAT the profiles User/Devices from one to the other. Also what are some of the challenges that we may encounter.