开发者

How do I solve "Can not find symbol" error?

http://pastey.net/143355-1qoa is my code for my java application so far. Each class I am writing has that file with the respective changes (below).

When I try to compile the code, I get the "cannot find symbol" error for each of my 6 classes.How should I go about fixing this?

I am attempting to compile with the following command:

C:\Program Files (x86)\Java\jdk1.6.0_22\bin>javac C:\Divelog\DiveLog.java

Please keep in mind that I am a complete noob with java programming. If there is an amazing source to learn java, please tell me of it if you can.

Thanks in advance.

package divelog;
/**
* This class creates the content on the
* Welcome tabbed pane in the Dive Log
* application.
* @version 1.0
*/
//import for buttons, labels, and images
import javax.swing.*; 
//import for layout manager
import java.awt.*; 

public class Resources extends JPanel
{ //Opens class 


}//Closes class 

Edit:

Error Message:

C:\Divelog\DiveLog.java:62: connot find symbol

symbol : class Welcome

location: class divelog.DiveLog

开发者_开发问答 new Welcome (),

C:\Divelog\DiveLog.java:68: cannot find symbol

symbol : class Diver

location: class divelog.DiveLog

new Diver (),

C:\Divelog\DiveLog.java:73: cannot find symbol

symbol : class Dives

location: class divelog.DiveLog

new Dives (),

C:\Divelog\DiveLog.java:78: cannot find symbol

symbol : class Statistics

location: class divelog.DiveLog

new Statistics (),

C:\Divelog\DiveLog.java:83: cannot find symbol

symbol : class WebSite location: class divelog.DiveLog

new WebSite (),

C:\Divelog\DiveLog.java:87: cannot find symbol

symbol : class Resources

location: class divelog.DiveLog

new Resources (),

6 errors


First of all, you should be running javac.exe from the project root. Never run it from the directory where you installed Java.

Try adding C:\Program Files (x86)\Java\jdk1.6.0_22\bin to your Windows PATH. Here's how to do it. Create a new command shell after you do it and type "set PATH" to verify that the new path has been added.

Navigate to c:\Divelog and create a directory named classes.

After you've done that, try compiling like this:

C:\Divelog javac -cp .;.\classes -d classes *.java

Run your code like this:

C:\Divelog java -cp .;.\classes divelog.DiveLog

Lose those awful comments - they're the worst.

{ //Opens class 


}//Closes class 


javac -cp C:\ divelog\DiveLog.java

It would be better to add C:\Program Files (x86)\Java\jdk1.6.0_22\bin>javac to your PATH environment variable (if it is not there) and compile from your project directory (and keep the project inside a directory and not at the root dir). Also, specify output directory for javac to put class files (-d).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜