• Post Reply Bookmark Topic Watch Topic
  • New Topic

[newbie] Compiling from the command line (CLASSPATH?)  RSS feed

 
Jon Camilleri
Ranch Hand
Posts: 664
Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have two source files Test.java and TalkingClock.java and I am trying to compile them from the command line. Test.java has the main method, because although I was under a different impression, TalkingClock.java would not compile on its own when I added a static void main (...) method within the class.

Microsoft Windows [Version 6.0.6001] Windows Server 2008 64 bit
Copyright (c) 2006 Microsoft Corporation. All rights reserved.

C:\Users\Administrator\Desktop\Java_console>javac -cp C:\Users\Administrator\Des
ktop\Java_console -g -version TalkingClock.java
javac 1.6.0_13

C:\Users\Administrator\Desktop\Java_console>javac Test.java
Test.java:12: cannot find symbol
symbol : class TalkingClock
location: class homenetwork.bkr.training.Test
TalkingClock clock = new TalkingClock(1000,true);
^
Test.java:12: cannot find symbol
symbol : class TalkingClock
location: class homenetwork.bkr.training.Test
TalkingClock clock = new TalkingClock(1000,true);
^
2 errors

C:\Users\Administrator\Desktop\Java_console>javac -cp C:\Users\Administrator\Des
ktop\Java_console Test.java
Test.java:12: cannot find symbol
symbol : class TalkingClock
location: class homenetwork.bkr.training.Test
TalkingClock clock = new TalkingClock(1000,true);
^
Test.java:12: cannot find symbol
symbol : class TalkingClock
location: class homenetwork.bkr.training.Test
TalkingClock clock = new TalkingClock(1000,true);
^
2 errors




 
Campbell Ritchie
Marshal
Posts: 56553
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do your classes have package declarations? That makes it more awkward to compile them. You could try putting "-cp ." (minus the "") after javac, which might help if it is a classpath problem. But I suspect it is a package structure problem.

Needless to say, that is a common problem: look at this old thread and if it doesn't help, come back with more details. Note I quoted 4 previous threads which you will probably find helpful too.

By the way: do you really want all your Java work on your desktop? When you open your command line, try

mkdir Java
cd Java

then you have a "Java" directory easily accessible from the command prompt, probably in "My Documents".
 
Jon Camilleri
Ranch Hand
Posts: 664
Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Do your classes have package declarations? That makes it more awkward to compile them. You could try putting "-cp ." (minus the "") after javac, which might help if it is a classpath problem. But I suspect it is a package structure problem.

Needless to say, that is a common problem: look at this old thread and if it doesn't help, come back with more details. Note I quoted 4 previous threads which you will probably find helpful too.

By the way: do you really want all your Java work on your desktop? When you open your command line, try

mkdir Java
cd Java

then you have a "Java" directory easily accessible from the command prompt, probably in "My Documents".


Thanks. Removing the package from the files and compiling them made the program work
 
Campbell Ritchie
Marshal
Posts: 56553
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome

Look upon compiling lots of things in packages from the command line as something to learn when you are feeling very brave
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!