Hi, I am getting a rather odd error message when I try compile a java program. I have attached the original java code and a copy of the error message in a .txt file. Any help you guys can offer will be much appreciated.

Attachments
init:
deps-clean:
Updating property file: /Users/ozsy88/NetBeansProjects/StringViewerGUI/build/built-clean.properties
Deleting directory /Users/ozsy88/NetBeansProjects/StringViewerGUI/build
clean:
init:
deps-jar:
Created dir: /Users/ozsy88/NetBeansProjects/StringViewerGUI/build
Updating property file: /Users/ozsy88/NetBeansProjects/StringViewerGUI/build/built-jar.properties
Created dir: /Users/ozsy88/NetBeansProjects/StringViewerGUI/build/classes
Created dir: /Users/ozsy88/NetBeansProjects/StringViewerGUI/build/empty
Compiling 2 source files to /Users/ozsy88/NetBeansProjects/StringViewerGUI/build/classes
/Users/ozsy88/NetBeansProjects/StringViewerGUI/src/StringViewerFrame.java:70: package org.jdesktop.layout does not exist
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 124, Short.MAX_VALUE)
/Users/ozsy88/NetBeansProjects/StringViewerGUI/src/StringViewerFrame.java:68: cannot find symbol
symbol  : method add(int,int,int)

Hi, I am getting a rather odd error message when I try compile a java program. I have attached the original java code and a copy of the error message in a .txt file. Any help you guys can offer will be much appreciated.

I'll help you by offering some friendly advice here

don't just attach your code and errors and assume we have the time, or every moment work on a pc with Java runtime installed on it.
show the relevant code and the error messages you get in your post, that would save us a lot of work and make us more willing to help you out

Edit: I've just read the last line of your error-message (about all the effort I was going to put into it)
seems to me that you're calling a non existing method.

Edited 6 Years Ago by stultuske: added some info

I thought it would be easier to just attach the files rather than plaguing this thread with lots of source code lol. I don't have a problem with posting the code here so thats what I will do. Thank you for your advice.

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.StringTokenizer;


class StringViewer
{
    private String filename;
    private ArrayList<String> list;
    private int blocksize = 16;

    public StringViewer(String fn)
    {
    filename = fn;
    list = new ArrayList<String>();
    }

    public void readFile() throws IOException
    {
    // Should throw out all the old stuff in list
    InputStream fin =
        new FileInputStream(filename);

    byte[] b = new byte[blocksize];

    while (fin.read(b) > 0)
        {
        String s = new String(b,"UTF-8");
        list.add(s);
        }

    fin.close();
    }

    public void writeFile() throws IOException
    {
    byte[] blanks = "                ".getBytes("UTF-8"); //horrid hack

    OutputStream fout =
        new FileOutputStream(filename);    // no autoflush here

    for(String s: list)
        {
        byte[] b = s.getBytes("UTF-8");
        if(b.length > blocksize)
            {
            fout.write(b,0,blocksize);
            }
        else
            {
            fout.write(b);
            fout.write(blanks,0,blocksize-b.length);
            }
        }

    fout.close();
    }

    public void add(String s)
    {
    list.add(s);
    }

    public void list()
    {
    for(String s: list)
        System.out.println(s);
    }

    public String get()
    {
        String alls = "";
        for(String s: list)
            alls += s+"\n";
        return alls;
    }

    public void set(String s)
    {
        StringTokenizer str = new StringTokenizer(s,"\n");
        while(str.hasMoreTokens())
                list.add(str.nextToken());
    }
}

Edited 3 Years Ago by mike_2000_17: Fixed formatting

import java.io.IOException;
import javax.swing.GroupLayout;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * StringViewerFrame.java
 *
 * Created on 26-Mar-2010, 14:51:33
 */

/**
 *
 * @author lancasd
 */
public class StringViewerFrame extends javax.swing.JFrame {

    /** Creates new form StringViewerFrame */
    public StringViewerFrame() {
        sv = new StringViewer(filename);
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();
        jPanel1 = new javax.swing.JPanel();
        loadButton = new javax.swing.JButton();
        saveButton = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jTextArea1.setColumns(20);
        jTextArea1.setRows(5);
        jScrollPane1.setViewportView(jTextArea1);

        loadButton.setText("Load");
        loadButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                loadButtonActionPerformed(evt);
            }
        });

        saveButton.setText("Save");
        saveButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                saveButtonActionPerformed(evt);
            }
        });

        GroupLayout jPanel1Layout = new GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .add(49, 49, 49)
                .add(loadButton)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 124, Short.MAX_VALUE)
                .add(saveButton)
                .add(79, 79, 79))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .add(38, 38, 38)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(loadButton)
                    .add(saveButton))
                .addContainerGap(37, Short.MAX_VALUE))
        );

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 164, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 12, Short.MAX_VALUE)
                .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void loadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_loadButtonActionPerformed
        // TODO add your handling code here:
        try
        {
                sv.readFile();
            jTextArea1.setText(sv.get());
        }
        catch(IOException ioe)
        {
            ioe.printStackTrace();
        }
    }//GEN-LAST:event_loadButtonActionPerformed

    private void saveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveButtonActionPerformed
        // TODO add your handling code here:
        try
        {
                sv.set(jTextArea1.getText());
                sv.writeFile();

        }
        catch(IOException ioe)
        {
            ioe.printStackTrace();
        }
    }//GEN-LAST:event_saveButtonActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new StringViewerFrame().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextArea jTextArea1;
    private javax.swing.JButton loadButton;
    private javax.swing.JButton saveButton;
    // End of variables declaration//GEN-END:variables
    private StringViewer sv;
    private String filename = "temp.txt";
}

Edited 3 Years Ago by mike_2000_17: Fixed formatting

init:
deps-clean:
Updating property file: /Users/ozsy88/NetBeansProjects/StringViewerGUI/build/built-clean.properties
Deleting directory /Users/ozsy88/NetBeansProjects/StringViewerGUI/build
clean:
init:
deps-jar:
Created dir: /Users/ozsy88/NetBeansProjects/StringViewerGUI/build
Updating property file: /Users/ozsy88/NetBeansProjects/StringViewerGUI/build/built-jar.properties
Created dir: /Users/ozsy88/NetBeansProjects/StringViewerGUI/build/classes
Created dir: /Users/ozsy88/NetBeansProjects/StringViewerGUI/build/empty
Compiling 2 source files to /Users/ozsy88/NetBeansProjects/StringViewerGUI/build/classes
/Users/ozsy88/NetBeansProjects/StringViewerGUI/src/StringViewerFrame.java:70: package org.jdesktop.layout does not exist
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 124, Short.MAX_VALUE)
/Users/ozsy88/NetBeansProjects/StringViewerGUI/src/StringViewerFrame.java:68: cannot find symbol
symbol : method add(int,int,int)
location: class javax.swing.GroupLayout.SequentialGroup
.add(49, 49, 49)
/Users/ozsy88/NetBeansProjects/StringViewerGUI/src/StringViewerFrame.java:66: cannot find symbol
symbol : variable LEADING
location: class javax.swing.GroupLayout
jPanel1Layout.createParallelGroup(GroupLayout.LEADING)
/Users/ozsy88/NetBeansProjects/StringViewerGUI/src/StringViewerFrame.java:78: package org.jdesktop.layout does not exist
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
/Users/ozsy88/NetBeansProjects/StringViewerGUI/src/StringViewerFrame.java:77: cannot find symbol
symbol : method add(int,int,int)
location: class javax.swing.GroupLayout.SequentialGroup
.add(38, 38, 38)
/Users/ozsy88/NetBeansProjects/StringViewerGUI/src/StringViewerFrame.java:75: package org.jdesktop.layout does not exist
jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
/Users/ozsy88/NetBeansProjects/StringViewerGUI/src/StringViewerFrame.java:84: package org.jdesktop.layout does not exist
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
/Users/ozsy88/NetBeansProjects/StringViewerGUI/src/StringViewerFrame.java:84: package org.jdesktop.layout does not exist
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
/Users/ozsy88/NetBeansProjects/StringViewerGUI/src/StringViewerFrame.java:92: package org.jdesktop.layout does not exist
.add(org.jdesktop.layout.GroupLayout.TRAILING, jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE))
/Users/ozsy88/NetBeansProjects/StringViewerGUI/src/StringViewerFrame.java:92: package org.jdesktop.layout does not exist
.add(org.jdesktop.layout.GroupLayout.TRAILING, jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE))
/Users/ozsy88/NetBeansProjects/StringViewerGUI/src/StringViewerFrame.java:91: package org.jdesktop.layout does not exist
.add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
/Users/ozsy88/NetBeansProjects/StringViewerGUI/src/StringViewerFrame.java:91: package org.jdesktop.layout does not exist
.add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
/Users/ozsy88/NetBeansProjects/StringViewerGUI/src/StringViewerFrame.java:91: package org.jdesktop.layout does not exist
.add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
/Users/ozsy88/NetBeansProjects/StringViewerGUI/src/StringViewerFrame.java:90: package org.jdesktop.layout does not exist
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
/Users/ozsy88/NetBeansProjects/StringViewerGUI/src/StringViewerFrame.java:87: package org.jdesktop.layout does not exist
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
/Users/ozsy88/NetBeansProjects/StringViewerGUI/src/StringViewerFrame.java:101: package org.jdesktop.layout does not exist
.add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
/Users/ozsy88/NetBeansProjects/StringViewerGUI/src/StringViewerFrame.java:101: package org.jdesktop.layout does not exist
.add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
/Users/ozsy88/NetBeansProjects/StringViewerGUI/src/StringViewerFrame.java:101: package org.jdesktop.layout does not exist
.add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
/Users/ozsy88/NetBeansProjects/StringViewerGUI/src/StringViewerFrame.java:100: package org.jdesktop.layout does not exist
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 12, Short.MAX_VALUE)
/Users/ozsy88/NetBeansProjects/StringViewerGUI/src/StringViewerFrame.java:99: package org.jdesktop.layout does not exist
.add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 164, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
/Users/ozsy88/NetBeansProjects/StringViewerGUI/src/StringViewerFrame.java:99: package org.jdesktop.layout does not exist
.add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 164, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
/Users/ozsy88/NetBeansProjects/StringViewerGUI/src/StringViewerFrame.java:96: package org.jdesktop.layout does not exist
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
22 errors
/Users/ozsy88/NetBeansProjects/StringViewerGUI/nbproject/build-impl.xml:413: The following error occurred while executing this line:
/Users/ozsy88/NetBeansProjects/StringViewerGUI/nbproject/build-impl.xml:199: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 1 second)

lol omg there was no point in posting all of this because I just had that light bulb moment and figured it out. I forgot to add the the Swing Layout Extension in the Libraries.... blame my professor who is supposed to be a Dr in his field. NooB!

This question has already been answered. Start a new discussion instead.