Advanced Search

Results 1 to 2 of 2

Thread: Cannot find symbol error

  1. #1
    Join Date
    Dec 2008
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Cannot find symbol error

    Can anyone tell me how to resolve the following compile-time error?

    TestUserInterface.java:5: cannot find symbol
    symbol: class UserInterface
    location: class projects.web.TestUserInterface
    UserInterface ui = new UserInterface();
    I have two classes: UserInterface and TestUserInterface. Both are in the same package.

    To compile and run them I use the following cmds respectively:

    Code:
    javac -d ..\classes projects\web\TestUserInterface.java
    Code:
    java -cp ..\classes projects.web.TestUserInterface
    Following is the code for both classes:

    Code:
    package projects.web;
     
    import java.awt.*;
    import javax.swing.*;
     
    public class UserInterface extends JFrame{
    	
    	JPanel menuPanel = new JPanel();
    	JPanel contentPanel = new JPanel();
    	JPanel selectionPanel = new JPanel();
    	
    	JButton save = new JButton("Save");
    	JButton addFiles = new JButton("Add");
    	
    	public UserInterface(){
    	super("File Upload");
    	setSize(500, 500);
    	
    	menuPanel.add(addFiles);
    	selectionPanel.add(save);
    	
    	setLayout(new BorderLayout());
    	add(menuPanel, BorderLayout.NORTH);
    	add(contentPanel, BorderLayout.CENTER);
    	add(selectionPanel, BorderLayout.SOUTH);
    	
    	} // end constructor
        
    } // end UserInterface clas
    Code:
    package projects.web;
     
    public class TestUserInterface{
    	public static void main(String[] args){
    		UserInterface ui = new UserInterface();
    	}
    } // end TestUserInterface class
    Last edited by dan0; 02-28-2009 at 08:16 PM.

  2. #2
    Join Date
    Dec 2008
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Problem was the code; it was creating the interface, but not displaying it. To resolve problem needed to add:
    Code:
    setVisible(true);
    in UserInterface constructor.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •