File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java 7: cannot find symbol

 
Preet Dhillon
Greenhorn
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 103
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Kanwal,

Are those two classes remaining in the same package?
 
Preet Dhillon
Greenhorn
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
They are in the same folder.
 
Henry Wong
author
Marshal
Pie
Posts: 20836
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Anoobkumar Padmanabhan
Ranch Hand
Posts: 103
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But it works fine for me..
without any compilation errors.
 
Preet Dhillon
Greenhorn
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic