aspose file tools*
The moose likes Beginning Java and the fly likes java 7: cannot find symbol Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "java 7: cannot find symbol" Watch "java 7: cannot find symbol" New topic
Author

java 7: cannot find symbol

Preet Dhillon
Greenhorn

Joined: May 20, 2008
Posts: 24
I am trying the very first sample from Java's Programming Language book for course SL-275-SE6 called TestGreeting. Here is the code:

TestGreeting.java

//
// Sample "Hello World" application
//

public class TestGreeting {
public static void main (String[] args) {
Greeting hello = new Greeting();
hello.greet();

}
}

Greeting.java

public class Greeting {
public void greet() {
System.out.println("hi");
}
}

When I go to compile TestGreeting.Java, I get an error message
7: cannot find symbol
symbol : class Greeting
location : class TestGreeting
Greeting hello = new Greeting();

I've tried the HelloWorldApp and it comiles and run
class HelloWorldApp {
public static void main(String[] args) {
System.out.println("Hello World!"); // Display the string.
}
}


I don't have admin priviliges on my work computer. My jdk is installed on c:/Program Files/Java/jdk1.6.0_06/bin

My work directory is on h:/Java

I've been searching the error and the posts are pointing towards setpath. I've tried different commads but I am still not having any success.

Anyone has encountered this error - How can I resolve it?

Thanks in advance!
Anoobkumar Padmanabhan
Ranch Hand

Joined: Aug 08, 2007
Posts: 103
Hi Kanwal,

Are those two classes remaining in the same package?


Thanks<br /> <br />Anoobkumar<br />SCJP 1.5
Preet Dhillon
Greenhorn

Joined: May 20, 2008
Posts: 24
They are in the same folder.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18133
    
  39

Originally posted by Kanwal Dhatt:
They are in the same folder.


Do you have a classpath assigned? And if you do, is that folder in the classpath?

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Anoobkumar Padmanabhan
Ranch Hand

Joined: Aug 08, 2007
Posts: 103
But it works fine for me..
without any compilation errors.
Preet Dhillon
Greenhorn

Joined: May 20, 2008
Posts: 24
Do you have a classpath assigned? And if you do, is that folder in the classpath?


I don't think I've been doing it correctly.

I am working on windows and here is what I am doing:

c:\Program Files\Java\jdk1.6.0_06\bin>javac -classpath H:\java\TestGreeting.java


I get the following message:
javac: no source files...


Is the syntax for my set classpath correct?
If I don't have admin priviliges to my computer, Can I still assign classpath?

Thanks!
[ October 30, 2008: Message edited by: Kanwal dhatt ]
Preet Dhillon
Greenhorn

Joined: May 20, 2008
Posts: 24
Issue resolved

Once set the CLASSPATH correctly by -
c:\> set CLASSPATH=H:\Java\test

I was able to compile and run the prorgam

Thanks!
[ October 31, 2008: Message edited by: Kanwal dhatt ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java 7: cannot find symbol
 
Similar Threads
Classpath problem when trying to access packages
Exception in thread "main" java.lang. NoClassDefFoundError: HelloWorldApp
Fresh SDK Install Won't Compile?
Error by compiling textfile Could not find the main class: HelloWorldapp. Program will exit
hello world code