Javac - Error Message

Does anyone know what the following error message refers to?
C:\>javac HelloWorld.java
error: cannot read: HelloWorld.java
1 error
Thanks!

Open a DOS window and CD to the directory where you think your source code file is. Then do a DIR command. Make sure the file exists and is named what you think. If the source code defines a class named HelloWorld, then it should be saved in a file named HelloWorld.java.
If you use a text editor like Notepad, it may have saved the file with a .txt extention - HelloWorld.java.txt - even though you put HelloWorld.java into the SaveAs dialog. If this is your problem, a quick work around is to put quotes around the file name in Notepad's SaveAs dialog. Or, add .java as a text file name extention.
Can't take credit...Post by atmguy

Similar Messages

  • Are javac error messages documented with comprehensive explanations

    Hi all:
    Are the error messages which javac produces documented?
    Can anyone recommend a source which explains exactly what the message is trying to tell the beginner?
    Often the meaning of the message is clear. But frequently one looks at the message and wonders exactly what the compiler is trying to tell you and how to go about fixing it.
    By the way, I am using JDK 1.3.1. I did try searching the forum because I am sure this question has been asked but I couldn't phrase the query so that it gave a reasonable number of items to look at.
    Thanks all
    Bill

    One good tutorial on the meaning of the the various common javac error messages can be found here: http://mindprod.com/errormessages.html
    Roedy's stuff is usually quite accurate and reasonably up to date. You might also want to peek around the rest of his Java Glossary - it's got a lot of great info.
    Chuck

  • Javac.exe Error Message

    Hey there,
    I recently Installed jdk1.2.2 on my home computer and now every time I go to compile a programe I get an error message which says Javac.exe has encountered a problem and needs to shutdown. Please contact windows then it says send error report or dont send?! I recently had to reinstall windows XP :( so would this have anything to do with it? Before I had to re-install XP jdk ran with no problems,
    Anyone with any ans I'd be delighted to hear
    Thanks!

    Do you have a Pentium 4 (or new Celeron) computer? It could be a problem with symcjit.dll. Some versions do not work in Pentium 4 computers. Upgrade your JDK version, or make it work in interpreted mode (
    before calling javac.exe, run the following command in the Command Prompt:
    SET JAVA_COMPILER=none
    Your compiling will be deadly slow, but it could work.

  • Problem with JDK 6 update 5 - Error Message says cant find java compiler

    Hi i am a complete beginner to programming and i am having trouble with the latest java development kit. jdk 6 update 5.
    The problem is i have set the path and the program cant find my compiler.
    I have installed the latest java development kit 6 update 5 on my windows xp machine.
    I have created a simple program as shown below:
    class Hello
         public static void main(String[] args)
                   System.out.println("Hello from java");
    saved the file to my desktop as Hello.java
    I have set the path variable like so:
    Go to control panel then click system icon then click advanced tab then click environmental variables.
    Now in system variables the path is shown as this - %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Java\jdk1.6.0_05\bin;C:\Program Files\QuickTime\QTSystem\;c:\Program Files\Microsoft SQL Server\90\Tools\binn\
    I then add this to the end;C:\Program Files\Java\jdk1.6.0_05\bin
    This is the location to the things like compiler, applet viewer etc.
    No in the command prompt i type javac Hello.java and i get this error message:
    C:\> javac Hello.java
    javac: file not found: Hello.java
    Usage: javac <options> <source files>
    use -help for a list of possible options
    The jdk is installed properly im sure but it can find my compiler.
    What mistake have i made in setting the path because im guessing that is related to the problem?
    Could someone out there please help me?
    Thank You
    Rafeeq

    saved the file to my desktop as Hello.java
    C:\> javac Hello.javaC:\ is not the desktop!
    The jdk is installed properly im sure but it can find my compiler.Of course it can! It just can't find the file you are trying to compile, because that's not in the root directory.
    I suggest you make a directory C:\java and save your source file there rather than on the desktop. In the command prompt, enter cd \java to make it the current working directory and then enter javac Hello.java.
    @Pravin: The question is about compiling, not running. CLASSPATH has nothing to do with this problem.
    db

  • Getting error message Cannot Resolve Symbol when trying to compile a class

    Hello All -
    I am getting an error message cannot resolve symbol while trying to compile a java class that calls another java class in the same package. The called class compiles fine, but the calling class generates
    the following error message:
    D:\Apache Tomcat 4.0\webapps\examples\WEB-INF\classes\cal>javac
    ConnectionPool.java
    ConnectionPool.java:158: cannot resolve symbol
    symbol : class PooledConnection
    location: class cal.ConnectionPool
    private void addConnection(PooledConnection value) {
    ^
    ConnectionPool.java:144: cannot resolve symbol
    symbol : class PooledConnection
    location: class cal.ConnectionPool
    PooledConnection pcon = new PooledConnection(con);
    ^
    ConnectionPool.java:144: cannot resolve symbol
    symbol : class PooledConnection
    location: class cal.ConnectionPool
    PooledConnection pcon = new PooledConnection(con);
    The code is listed as follows for PooledConnection.java (it compiles fine)
    package cal;
    import java.sql.*;
    public class PooledConnection {
    // Real JDBC Connection
    private Connection connection = null;
    // boolean flag used to determine if connection is in use
    private boolean inuse = false;
    // Constructor that takes the passed in JDBC Connection
    // and stores it in the connection attribute.
    public PooledConnection(Connection value) {
    if ( value != null ) {
    connection = value;
    // Returns a reference to the JDBC Connection
    public Connection getConnection() {
    // get the JDBC Connection
    return connection;
    // Set the status of the PooledConnection.
    public void setInUse(boolean value) {
    inuse = value;
    // Returns the current status of the PooledConnection.
    public boolean inUse() {
    return inuse;
    // Close the real JDBC Connection
    public void close() {
    try {
    connection.close();
    catch (SQLException sqle) {
    System.err.println(sqle.getMessage());
    Now the code for ConnectionPool.java class that gives the cannot
    resolve symbol error
    package cal;
    import java.sql.*;
    import java.util.*;
    public class ConnectionPool {
    // JDBC Driver Name
    private String driver = null;
    // URL of database
    private String url = null;
    // Initial number of connections.
    private int size = 0;
    // Username
    private String username = new String("");
    // Password
    private String password = new String("");
    // Vector of JDBC Connections
    private Vector pool = null;
    public ConnectionPool() {
    // Set the value of the JDBC Driver
    public void setDriver(String value) {
    if ( value != null ) {
    driver = value;
    // Get the value of the JDBC Driver
    public String getDriver() {
    return driver;
    // Set the URL Pointing to the Datasource
    public void setURL(String value ) {
    if ( value != null ) {
    url = value;
    // Get the URL Pointing to the Datasource
    public String getURL() {
    return url;
    // Set the initial number of connections
    public void setSize(int value) {
    if ( value > 1 ) {
    size = value;
    // Get the initial number of connections
    public int getSize() {
    return size;
    // Set the username
    public void setUsername(String value) {
    if ( value != null ) {
    username = value;
    // Get the username
    public String getUserName() {
    return username;
    // Set the password
    public void setPassword(String value) {
    if ( value != null ) {
    password = value;
    // Get the password
    public String getPassword() {
    return password;
    // Creates and returns a connection
    private Connection createConnection() throws Exception {
    Connection con = null;
    // Create a Connection
    con = DriverManager.getConnection(url,
    username, password);
    return con;
    // Initialize the pool
    public synchronized void initializePool() throws Exception {
    // Check our initial values
    if ( driver == null ) {
    throw new Exception("No Driver Name Specified!");
    if ( url == null ) {
    throw new Exception("No URL Specified!");
    if ( size < 1 ) {
    throw new Exception("Pool size is less than 1!");
    // Create the Connections
    try {
    // Load the Driver class file
    Class.forName(driver);
    // Create Connections based on the size member
    for ( int x = 0; x < size; x++ ) {
    Connection con = createConnection();
    if ( con != null ) {
    // Create a PooledConnection to encapsulate the
    // real JDBC Connection
    PooledConnection pcon = new PooledConnection(con);
    // Add the Connection to the pool.
    addConnection(pcon);
    catch (Exception e) {
    System.err.println(e.getMessage());
    throw new Exception(e.getMessage());
    // Adds the PooledConnection to the pool
    private void addConnection(PooledConnection value) {
    // If the pool is null, create a new vector
    // with the initial size of "size"
    if ( pool == null ) {
    pool = new Vector(size);
    // Add the PooledConnection Object to the vector
    pool.addElement(value);
    public synchronized void releaseConnection(Connection con) {
    // find the PooledConnection Object
    for ( int x = 0; x < pool.size(); x++ ) {
    PooledConnection pcon =
    (PooledConnection)pool.elementAt(x);
    // Check for correct Connection
    if ( pcon.getConnection() == con ) {
    System.err.println("Releasing Connection " + x);
    // Set its inuse attribute to false, which
    // releases it for use
    pcon.setInUse(false);
    break;
    // Find an available connection
    public synchronized Connection getConnection()
    throws Exception {
    PooledConnection pcon = null;
    // find a connection not in use
    for ( int x = 0; x < pool.size(); x++ ) {
    pcon = (PooledConnection)pool.elementAt(x);
    // Check to see if the Connection is in use
    if ( pcon.inUse() == false ) {
    // Mark it as in use
    pcon.setInUse(true);
    // return the JDBC Connection stored in the
    // PooledConnection object
    return pcon.getConnection();
    // Could not find a free connection,
    // create and add a new one
    try {
    // Create a new JDBC Connection
    Connection con = createConnection();
    // Create a new PooledConnection, passing it the JDBC
    // Connection
    pcon = new PooledConnection(con);
    // Mark the connection as in use
    pcon.setInUse(true);
    // Add the new PooledConnection object to the pool
    pool.addElement(pcon);
    catch (Exception e) {
    System.err.println(e.getMessage());
    throw new Exception(e.getMessage());
    // return the new Connection
    return pcon.getConnection();
    // When shutting down the pool, you need to first empty it.
    public synchronized void emptyPool() {
    // Iterate over the entire pool closing the
    // JDBC Connections.
    for ( int x = 0; x < pool.size(); x++ ) {
    System.err.println("Closing JDBC Connection " + x);
    PooledConnection pcon =
    (PooledConnection)pool.elementAt(x);
    // If the PooledConnection is not in use, close it
    if ( pcon.inUse() == false ) {
    pcon.close();
    else {
    // If it is still in use, sleep for 30 seconds and
    // force close.
    try {
    java.lang.Thread.sleep(30000);
    pcon.close();
    catch (InterruptedException ie) {
    System.err.println(ie.getMessage());
    I am using Sun JDK Version 1.3.0_02" and Apache/Tomcat 4.0. Both the calling and the called class are in the same directory.
    Any help would be greatly appreciated.
    tnx..
    addi

    Is ConnectionPool in this "cal" package as well as PooledConnection? From the directory you are compiling from it appears that it is. If it is, then you are compiling it incorrectly. To compile ConnectionPool (and PooledConnection similarly), you must change the current directory to the one that contains cal and type
    javac cal/ConnectionPool.

  • Error message in an odd location

    I have this code snippet:
    URL urlShoppingCartPage = new URL("http://www.example.com/cgi-bin/...");
    URLConnection URLConn_ShoppingCartPage = new urlShoppingCartPage.openConnection(); // line 138
    // more code...
    InputStream is_ShoppingCartPage = new URLConn_ShoppingCartPage.getInputStream(); // line 167
    I get this error message:
    C:\>javac FormPOST_Henrys.java
    FormPOST_Henrys.java:138: package urlShoppingCartPage does not exist
    URLConnection URLConn_ShoppingCartPage = new urlShoppingCartPage.openCon
    nection();
    ^
    FormPOST_Henrys.java:167: package URLConn_ShoppingCartPage does not exist
    InputStream is_ShoppingCartPage = new URLConn_ShoppingCartPage.getInputS
    tream();
    ^
    2 errors
    C:\>
    the program successfully compiles using URLConnection object and InputStream object further towards the top of the code file. Why does it not compile now?

    The object is already created (new URL(...)) where it was declared, so remove the two other references to 'new'.
    If you have trouble implementing that advice, try posting an SSCCE. It should take no more than a dozen lines of code to reproduce the errors.
    Also, please use the code tags when posting code or code snippets. To do that, select the code and click the CODE button on the message input form.

  • Wrong character encoding in error messages

    The Java compiler can be adjusted to source file encoding with the option javac -encoding ...
    The Java runtime can be adjusted to terminal encoding with java -Dfile.encoding=...
    While this appears somehow inconsistent, it works and can be used e.g. when running the tools from Cygwin (the POSIX layer on Windows) which uses UTF-8 by default, while Java, following the Windows mechanism, uses some other character encoding by default (this works more seemlessly on Unix/Linux, by the way).
    Now if I compile UTF-8 source with non-ASCII characters, and there is an error message related to them, the error message printed to the console will not be UTF-8 encoded, resulting in mangled text output.
    (Arguably, source and terminal encoding could be different, but then there is no option available to the compiler to adjust this;
    it does not accept -Dfile.encoding=....)
    Example: Error message looks like this:
    FM.java:1: error: class, interface, or enum expected
    b▒h
    While the string is actually "bäh" in the source.
    This is a bug. Any proper place to actually report a bug?
    Edited by: 994195 on 15-Mar-2013 09:42

    I'll ignore you just blatantly assuming it is a bug because you say so, you did not think to type "java report bug" into Google?

  • I keep gettin this error message when i try to compile can't fix

    MY CODE
    import java.text.DecimalFormat;
    public class MotelBase{
    private int nite;
    private int numadult;
    private int numchild;
    final double ADULT_RATE = 25.0;
    final double CHILD_RATE = 8.0;
    public MotelBase (int inNite, int inNumAdult, int inNumChild){
         nite = inNite;
         numadult = inNumAdult;
         numchild = inNumChild;}
    public int getNumAdult(){return numadult;}
    public int getNumChild(){return numchild;}
    public int getNite(){return nite;}
    public double getAchg(){return numadult * nite * ADULT_RATE;}
    public double getCchg(){return numchild * nite * CHILD_RATE;}
    public double getBase;{return (getAchg + getCchg);}
    public double getTax;{return (getBase) * .10;}
    public double getTotal;{return (getTax) + (getBase);}
    public void setNite(int inNite){nite = inNite;}
    public void setNumAdult(int inNumAdult){numadult = inNumAdult;}
    public void setNumChild(int inNumChild){numchild = inNumChild;}
    public String toString(){return "Number of Adults: " + this.numadult + "\n" +
                                    "Number of Children: " + this.numchild + "\n" +
                                    "Number of Nights: " + this.nite + "\n" +
                                    "Base rate: " + this.getBase + "\n" ;}}
    **Here are the error messages when i compile**
    javac -d . -g -classpath . MotelBase.java
    MotelBase.java:17: return outside method
    public double getBase;{return (getAchg + getCchg);}
    ^
    MotelBase.java:18: return outside method
    public double getTax;{return (getBase) * .10;}
    ^
    MotelBase.java:19: return outside method
    public double getTotal;{return (getTax) + (getBase);}
    ^
    3 errors
    Can anyone help me

    so i removes the semi's and added ()'s
    public double getBase(){return (getAchg) + (getCchg);}
    public double getTax(){return (getBase) * .10;}
    public double getTotal(){return (getTax) + (getBase);}
    and this happened
    javac -d . -g -classpath . MotelBase.java
    MotelBase.java:17: cannot find symbol
    symbol : variable getAchg
    location: class MotelBase
    public double getBase(){return (getAchg) + (getCchg);}
    ^
    MotelBase.java:17: illegal start of type
    public double getBase(){return (getAchg) + (getCchg);}
    ^
    MotelBase.java:17: cannot find symbol
    symbol : variable getCchg
    location: class MotelBase
    public double getBase(){return (getAchg) + (getCchg);}
    ^
    MotelBase.java:17: illegal start of type
    public double getBase(){return (getAchg) + (getCchg);}
    ^
    MotelBase.java:17: incompatible types
    found : java.lang.String
    required: double
    public double getBase(){return (getAchg) + (getCchg);}
    ^
    MotelBase.java:18: cannot find symbol
    symbol : variable getBase
    location: class MotelBase
    public double getTax(){return (getBase) * .10;}
    ^
    MotelBase.java:18: illegal start of type
    public double getTax(){return (getBase) * .10;}
    ^
    MotelBase.java:19: cannot find symbol
    symbol : variable getTax
    location: class MotelBase
    public double getTotal(){return (getTax) + (getBase);}
    ^
    MotelBase.java:19: illegal start of type
    public double getTotal(){return (getTax) + (getBase);}
    ^
    MotelBase.java:19: cannot find symbol
    symbol : variable getBase
    location: class MotelBase
    public double getTotal(){return (getTax) + (getBase);}
    ^
    MotelBase.java:19: illegal start of type
    public double getTotal(){return (getTax) + (getBase);}
    ^
    MotelBase.java:19: incompatible types
    found : java.lang.String
    required: double
    public double getTotal(){return (getTax) + (getBase);}
    ^
    MotelBase.java:26: cannot find symbol
    symbol : variable getBase
    location: class MotelBase
    "Base rate: " + this.getBase + "\n" ;}}
    ^
    13 errors
    it seem like everytime i fix something there is a virtual landrush of errors, i appreciate all of your help thank you for taking the time to answer my questions

  • Error Message When Running A JSP?

    I have been trying to run an example JSP using Apache Tomcat 3.0 and have been recieving the following error message can anyone tell me why this is?
    Error: 500
    Location: /coreservlets/jspages/date.jsp
    Internal Servlet Error:
    javax.servlet.ServletException: sun/tools/javac/Main
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:508)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
         at org.apache.tomcat.core.Handler.service(Handler.java:287)
         at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
         at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:812)
         at org.apache.tomcat.core.ContextManager.service(ContextManager.java:758)
         at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:213)
         at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
         at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
         at java.lang.Thread.run(Thread.java:484)
    Root cause:
    java.lang.NoClassDefFoundError: sun/tools/javac/Main
         at org.apache.jasper.compiler.SunJavaCompiler.compile(SunJavaCompiler.java:136)
         at org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
         at org.apache.jasper.servlet.JspServlet.doLoadJSP(JspServlet.java:612)
         at org.apache.jasper.servlet.JasperLoader12.loadJSP(JasperLoader12.java:146)
         at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:542)
         at org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNecessary(JspServlet.java:258)
         at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:268)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:429)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:500)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
         at org.apache.tomcat.core.Handler.service(Handler.java:287)
         at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
         at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:812)
         at org.apache.tomcat.core.ContextManager.service(ContextManager.java:758)
         at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:213)
         at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
         at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
         at java.lang.Thread.run(Thread.java:484)
    Any help very much appreciated.
    Stu.

    This looks like a problem with environment variables being set wrong. Make sure your JAVA_HOME variable is set to C:\jdk1.4.0 (or whatever jdk you're using). Also, make sure the bin and lib subdirectories are included in your PATH. TOMCAT_HOME should also be set to the directory containing the webapps folder.

  • Error message in java console

    I am wondering if any of you can help me. My live scoring on my fantasy baseball site won't keep up to the minute stats, and I keep getting the following error message in my java console:
    Host Name: fdjs.baseball.sportsline.com
    Error loading class: zlBeanInfo
    java.lang.ClassFormatError
    Sat Aug 02 00:29:21 EDT 2003 set_machine_name (ws047.fl.sportsline.com,137 http://fdjs.baseball.sportsline.com/scoreboard/h2h/
    Error loading class: zlBeanInfo
    java.lang.ClassFormatError
    Thanks for your help!

    Hi,
    looks like some class got corrupted. Recompile or
    provide a new one
    http://galileo.spaceports.com/~ibidris/
    Do javac zbeanInfo.java in the directory of zbeaninfo.java

  • Got the error message ("Java(TM) Platform SE binary has stopped working")

    Hello Gurus,
    I installed java jdk1.6.0_24 in my laptop. After that i gave the command javac, i got the error message ("Java(TM) Platform SE binary has stopped working"). I willl highly appreciate any help on this.
    The OS on my laptop is Windows Vista Home Premium 64 bit.
    Thanks,
    Vish

    Vish,
    You may want to try one of the Java forums, as your question is specific to the JDK/JRE, and nothing to do with JDev/ADF. {forum:id=937} might be a good starting place.
    John

  • To get only the error messages???

    Hi,
    When i compile my java code i am getting warning errors also . Is there anyway to get only the error messages only, not the warning using
    javac or java???
    Thanks,
    JavaCrazyLover

    javac <option> <sourcefile>. if you use[b] -nowarn option you get only error message.
    if in the shell invoke only the command javac without option and sourcefile you see all option available. Bye

  • Error message when compiling

    Hello
    I am totally new to Java, but very fascinated. My first attempts however have failed and I do not know why:
    When compiling like:
    javac SystemInfo.java
    I get following Error Message:
    Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/tools/javac/Main
    My OS is Windows XP and I am pretty sure that I have set the path-variable correct (just followed the instructions of the book and had no problems).
    Could anyone help me with this problem, please?
    Thanks a lot
    mazarata

    Thanks a lot. The info, I have found about the error message is:
    If you see the error message "java.lang.NoClassDefFoundError: com/sun/tools/javac/Main" when you distribute an application, the JAVA_HOME variable is pointing to a J2SE JRE directory, not a J2SE SDK directory, as it should be. This module requires the JAVA_HOME variable to point to a J2SE SDK directory to resolve all library JAR file references.
    Well, I guess I folllow your advice and re-install Java, as I have not distributed any application.
    Thanks for your help
    mazarata

  • Error Message(I can't pickout the problem)

    I compiled my program and got the following error message.
    The code is long and i realise people have little time to spare
    but i would appreciate someone can tell me why.
    ===
    H:\myjava>javac LPCPROJECT1.java
    LPCPROJECT1.java:125: showSaveDialog(java.awt.Component) in javax.swing.JFileCho
    oser cannot be applied to (LPCPROJECT1.Savehandler)
    int result = fileChooser.showSaveDialog( this );
    ^
    LPCPROJECT1.java:169: inner classes cannot have static declarations
    public static void main (String [] args)
    ^
    2 errors
    ====
    import javax.swing.*;
    //import javax.swing.table.AbstractTableModel;
    import javax.swing.event.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    //import javax.swing.JTable;
    //import javax.swing.table.TableColumn;
    //import javax.swing.DefaultCellEditor;
    //import javax.swing.table.TableCellRenderer;
    //import javax.swing.table.DefaultTableCellRenderer;
    //import javax.swing.JScrollPane;
    //import javax.swing.JComboBox;
    //import javax.swing.JFrame;
    //import javax.swing.SwingUtilities;
    //import javax.swing.JOptionPane;
    public class LPCPROJECT1 extends JApplet
    { private int MemorySize=100;
    private JTextField MemoryContent[];
    private JLabel MemoryAddress[],MemoryAdd1,MemoryAdd2;
    private JPanel Memory1,Memory2,Memory3,Memory,Right,mainpane;
    private JScrollPane scrollPane1;
    private JButton load,save,clear,exit;
    private File fileName;
    public void init()
    { load=new JButton("LOAD");
    //run.setMinimumSize(new Dimension(170,40));
    //run.setPreferredSize(new Dimension(170,40));
    //run.setMaximumSize(new Dimension(170,40));
    save=new JButton("SAVE");
    Savehandler Sa=new Savehandler();
    save.addActionListener(Sa);
    clear=new JButton("CLEAR");
    exit=new JButton("EXIT");
    JPanel Memory1 = new JPanel();
    Memory1.setLayout(new FlowLayout());
    Memory1.add(load);
    Memory1.add(save);
    Memory1.add(clear);
    Memory1.add(exit);
    MemoryAdd1=new JLabel("MemoryAddress");
    MemoryAdd1.setBorder(BorderFactory.createLineBorder(Color.black));
    MemoryAdd1.setPreferredSize(new Dimension(147,45));
    MemoryAdd1.setMinimumSize(new Dimension(147,45));
    MemoryAdd1.setMaximumSize(new Dimension(147,45));
    MemoryAdd2=new JLabel("MemoryContent");
    MemoryAdd2.setBorder(BorderFactory.createLineBorder(Color.black));
    MemoryAdd2.setPreferredSize(new Dimension(147,45));
    MemoryAdd2.setMinimumSize(new Dimension(147,45));
    MemoryAdd2.setMaximumSize(new Dimension(147,45));
    Memory2=new JPanel();
    Memory2.setBackground(Color.red);
    Memory2.setLayout(new BoxLayout(Memory2, BoxLayout.X_AXIS));
    Memory2.setPreferredSize(new Dimension(295,45));
    Memory2.setMinimumSize(new Dimension(295,45));
    Memory2.setMaximumSize(new Dimension(295,45));
    MemoryAdd1.setAlignmentX (Component.CENTER_ALIGNMENT);
    Memory2.add(MemoryAdd1);
    MemoryAdd2.setAlignmentX (Component.CENTER_ALIGNMENT);
    Memory2.add(MemoryAdd2);
    MemoryAddress=new JLabel[MemorySize];
    for(int i=0;i<MemoryAddress.length;i++)
    { MemoryAddress[i]=new JLabel(" "+i);
    MemoryContent=new JTextField[MemorySize];
    for(int i=0;i<MemoryContent.length;i++)
    { MemoryContent[i]=new JTextField();
    Memory3=new JPanel();
    Memory3.setBackground(Color.red);
    Memory3.setLayout(new GridLayout(MemorySize+1,2));
    for(int i=0;i<MemorySize;i++)
    { Memory3.add(MemoryAddress[i]);
    Memory3.add(MemoryContent);
    scrollPane1=new JScrollPane(Memory3);
    scrollPane1.setPreferredSize(new Dimension(300, 570));
    scrollPane1.setMinimumSize(new Dimension(300, 570));
    scrollPane1.setMaximumSize(new Dimension(300, 570));
    Memory=new JPanel();
    Memory.setBackground(Color.green);
    Memory.setLayout(new BoxLayout(Memory, BoxLayout.Y_AXIS));
    Memory.setMinimumSize(new Dimension(300,650));
    Memory.setPreferredSize(new Dimension(300,650));
    Memory.setMaximumSize(new Dimension(300,650));
    Memory.add(Memory1);
    Memory.add(Memory2);
    Memory.add(scrollPane1);
    Right=new JPanel();
    Right.setBackground(Color.blue);
    //Right.setMinimumSize(new Dimension(295,650));
    //Right.setPreferredSize(new Dimension(295,650));
    //Right.setMaximumSize(new Dimension(295,650));
    mainpane=new JPanel();
    mainpane.setBackground(Color.magenta);
    mainpane.setMinimumSize(new Dimension(695,845));
    mainpane.setPreferredSize(new Dimension(695,845));
    mainpane.setMaximumSize(new Dimension(695,845));
    mainpane.setLayout(new BoxLayout(mainpane,BoxLayout.X_AXIS));
    mainpane.add(Memory);
    mainpane.add(Right);
    Container c=getContentPane();
    c.add(mainpane);
    private class Savehandler implements ActionListener
    { public void actionPerformed(ActionEvent event)
    { JFileChooser fileChooser = new JFileChooser();
    fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY );
    int result = fileChooser.showSaveDialog( this );
    // user clicked Cancel button on dialog
    if ( result == JFileChooser.CANCEL_OPTION )
    return;
    fileName = fileChooser.getSelectedFile();
    if ( fileName == null || fileName.getName().equals( "" ) )
    JOptionPane.showMessageDialog( null,"Invalid File Name",
    "Invalid File Name",
    JOptionPane.ERROR_MESSAGE );
    else
    { // Open the file
    try
    { FileWriter out = new FileWriter(fileName);
    for(int i=0;i<MemorySize;i++)
    { out.write(MemoryContent[i].getText() + "\n");
    out.close();
    //out = new FileOutputStream(fileName);
    //p = new PrintStream( out );
    catch ( IOException e )
    { JOptionPane.showMessageDialog( null,
    "Error Opening File", "Error",
    JOptionPane.ERROR_MESSAGE );
    catch(FileNotFoundException fnfe)
    { System.err.println("FileNotFoundException: " + fnfe.getMessage());
    catch(IOException ioe)
    { System.err.println("IOException: " + ioe.getMessage());
    public void load()
    public void clear()
    public void exit()
    public static void main (String [] args)
    { JFrame frame = new JFrame("LPC");
    frame.addWindowListener(new WindowAdapter()
    public void windowClosing(WindowEvent e)
    System.exit(0);
    LPCPROJECT1 LPC=new LPCPROJECT1();
    LPC.init();
    frame.getContentPane().add(LPC);
    frame.pack();
    frame.setSize(700,850);
    frame.setVisible(true);
    ====

    jkwhtfield replied before I finished formatting your code :P. But he's right, it should be outside SaveHandler like this:
    import javax.swing.*;
    //import javax.swing.table.AbstractTableModel;
    import javax.swing.event.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    //import javax.swing.JTable;
    //import javax.swing.table.TableColumn;
    //import javax.swing.DefaultCellEditor;
    //import javax.swing.table.TableCellRenderer;
    //import javax.swing.table.DefaultTableCellRenderer;
    //import javax.swing.JScrollPane;
    //import javax.swing.JComboBox;
    //import javax.swing.JFrame;
    //import javax.swing.SwingUtilities;
    //import javax.swing.JOptionPane;
    public class LPCPROJECT1 extends JApplet {
         private int MemorySize=100;
         private JTextField MemoryContent[];
         private JLabel MemoryAddress[],MemoryAdd1,MemoryAdd2;
         private JPanel Memory1,Memory2,Memory3,Memory,Right,mainpane;
         private JScrollPane scrollPane1;
         private JButton load,save,clear,exit;
         private File fileName;
         public void init() {
              load=new JButton("LOAD");
              //run.setMinimumSize(new Dimension(170,40));
              //run.setPreferredSize(new Dimension(170,40));
              //run.setMaximumSize(new Dimension(170,40));
              save = new JButton("SAVE");
              Savehandler Sa=new Savehandler();
              save.addActionListener(Sa);
              clear=new JButton("CLEAR");
              exit=new JButton("EXIT");
              JPanel Memory1 = new JPanel();
              Memory1.setLayout(new FlowLayout());
              Memory1.add(load);
              Memory1.add(save);
              Memory1.add(clear);
              Memory1.add(exit);
              MemoryAdd1=new JLabel("MemoryAddress");
              MemoryAdd1.setBorder(BorderFactory.createLineBorder(Color.black));
              MemoryAdd1.setPreferredSize(new Dimension(147,45));
              MemoryAdd1.setMinimumSize(new Dimension(147,45));
              MemoryAdd1.setMaximumSize(new Dimension(147,45));
              MemoryAdd2=new JLabel("MemoryContent");
              MemoryAdd2.setBorder(BorderFactory.createLineBorder(Color.black));
              MemoryAdd2.setPreferredSize(new Dimension(147,45));
              MemoryAdd2.setMinimumSize(new Dimension(147,45));
              MemoryAdd2.setMaximumSize(new Dimension(147,45));
              Memory2=new JPanel();
              Memory2.setBackground(Color.red);
              Memory2.setLayout(new BoxLayout(Memory2, BoxLayout.X_AXIS));
              Memory2.setPreferredSize(new Dimension(295,45));
              Memory2.setMinimumSize(new Dimension(295,45));
              Memory2.setMaximumSize(new Dimension(295,45));
              MemoryAdd1.setAlignmentX(Component.CENTER_ALIGNMENT);
              Memory2.add(MemoryAdd1);
              MemoryAdd2.setAlignmentX (Component.CENTER_ALIGNMENT);
              Memory2.add(MemoryAdd2);
              MemoryAddress=new JLabel[MemorySize];
              for(int x=0;x<MemoryAddress.length;x++) {
                   MemoryAddress[x]=new JLabel(" "+x);
              MemoryContent=new JTextField[MemorySize];
              for(int x=0;x<MemoryContent.length;x++) {
                   MemoryContent=new JTextField();
              Memory3=new JPanel();
              Memory3.setBackground(Color.red);
              Memory3.setLayout(new GridLayout(MemorySize+1,2));
              for(int i=0;i<MemorySize;i++) {
                   Memory3.add(MemoryAddress);
                   Memory3.add(MemoryContent);
              scrollPane1=new JScrollPane(Memory3);
              scrollPane1.setPreferredSize(new Dimension(300, 570));
              scrollPane1.setMinimumSize(new Dimension(300, 570));
              scrollPane1.setMaximumSize(new Dimension(300, 570));
              Memory=new JPanel();
              Memory.setBackground(Color.green);
              Memory.setLayout(new BoxLayout(Memory, BoxLayout.Y_AXIS));
              Memory.setMinimumSize(new Dimension(300,650));
              Memory.setPreferredSize(new Dimension(300,650));
              Memory.setMaximumSize(new Dimension(300,650));
              Memory.add(Memory1);
              Memory.add(Memory2);
              Memory.add(scrollPane1);
              Right=new JPanel();
              Right.setBackground(Color.blue);
              //Right.setMinimumSize(new Dimension(295,650));
              //Right.setPreferredSize(new Dimension(295,650));
              //Right.setMaximumSize(new Dimension(295,650));
              mainpane=new JPanel();
              mainpane.setBackground(Color.magenta);
              mainpane.setMinimumSize(new Dimension(695,845));
              mainpane.setPreferredSize(new Dimension(695,845));
              mainpane.setMaximumSize(new Dimension(695,845));
              mainpane.setLayout(new BoxLayout(mainpane,BoxLayout.X_AXIS));
              mainpane.add(Memory);
              mainpane.add(Right);
              Container c=getContentPane();
              c.add(mainpane);
         private class Savehandler implements ActionListener {
              public void actionPerformed(ActionEvent event) {
                   JFileChooser fileChooser = new JFileChooser();
                   fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY );
                   int result = fileChooser.showSaveDialog( this );
                   // user clicked Cancel button on dialog
                   if (result == JFileChooser.CANCEL_OPTION) return;
                   fileName = fileChooser.getSelectedFile();
                   if (fileName == null || fileName.getName().equals("")) {
                        JOptionPane.showMessageDialog(null,"Invalid File Name","Invalid File Name",JOptionPane.ERROR_MESSAGE);
                   else {
                   // Open the file
                        try {
                             FileWriter out = new FileWriter(fileName);
                             for(int i=0;i<MemorySize;i++) {
                                  out.write(MemoryContent.getText() + "\n");
                             out.close();
                             //out = new FileOutputStream(fileName);
                             //p = new PrintStream(out);
                        catch (IOException e) {
                             JOptionPane.showMessageDialog(null,"Error Opening File", "Error",JOptionPane.ERROR_MESSAGE);
                        catch(FileNotFoundException fnfe) {
                             System.err.println("FileNotFoundException: " + fnfe.getMessage());
                        catch(IOException ioe) {
                             System.err.println("IOException: " + ioe.getMessage());
              public void load() {}
              public void clear() {}
              public void exit() {}
         public static void main (String [] args) {
              JFrame frame = new JFrame("LPC");
              frame.addWindowListener(new WindowAdapter() {
                   public void windowClosing(WindowEvent e) {
                        System.exit(0);
              LPCPROJECT1 LPC=new LPCPROJECT1();
              LPC.init();
              frame.getContentPane().add(LPC);
              frame.pack();
              frame.setSize(700,850);
              frame.setVisible(true);
    }There are some other errors, but I think it's because you've commented out some stuff...

  • Saving Error Messages

    Is there a parameter for javac.exe that will save the error messages to a file (.txt)?

    I tried "javac ... 2>errors.txt" and it gives me:
    Invalid argument: 2
    ...

Maybe you are looking for

  • Can we add custom print button to crystal report launched using jsp

    Hi, I need to add a print icon in crystal report. My requirement states that I should not use the print button given in the taskbar of crystal report. Can this be done? Thanks

  • How can i save my settings configuration

    is there a way to save the browser config. so i can try the updated version & revert to the older if i decide without having to redo all the pref.settings/addons/plugins etc... (or is there a "config" file i can copy? where would it be located?) thx

  • SharePoint Online - Open large Doc Library With Explorer - "This folder is empty"

    I'm using a Document Library in SharePoint Online to store over 50,000 files at around 40gb. I am a Site Collection Administrator, and I am in the Site Owners group. I can open the library in a browser and it displays the files correctly: However, wh

  • I gotta access firefox to get on windows live messanger

    i downloaded Google chrome then got rod of it. know when i go to windows live messenger it shows up but cant access emails worked before. know i gotta go to msn.com to access my e-mail how do i fix this so i can click on windows live messenger and ac

  • Can't create root entry

    Ok guy's bit of a silly one ! created new root suffix, now trying to create new root object, however getting error mesage, must be Directory Manager, now, this is the strange bit !, I am directory manager. Any ideas ? TIA