• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

java 7: cannot find symbol  RSS feed

 
Greenhorn
Posts: 24
  • 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!
 
Ranch Hand
Posts: 105
  • 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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
They are in the same folder.
 
author
Sheriff
Posts: 23601
138
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • 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: 105
  • 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
  • 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
  • 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 ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!