0

I can't seem to run these files without getting a cannot symbol error.

I run the exact same code on another computer and it works. I'm guessing its a problem with my path? But both java and javac work in cmd.

Thanks so much tell me if you have any questions.

Here is my two files I cant connect (EXACT same on both computers, including fileName).

Both files are in the same folder and javac is installed on both the computers.

Test.java file

public class Test {
  public Test(){
    System.out.println("it's working");
  }
 }

TestRun.java file

public class TestRun {
  public static void main(String[] args) {
    new Test();
}
} 

Commands:

$ javac Test.java
$ javac TestRun.java
$ java TestRun

Output:

it's working

But the same is not working in another computer

Theodore Norvell
  • 15,366
  • 6
  • 31
  • 45
Dan Rasmuson
  • 5,705
  • 5
  • 29
  • 45
  • In machine where it is not working did you try javac on both java source first ? – jmj Mar 28 '14 at 17:36
  • 1
    In your another PC where it is not working, have you added class to classpath? – Pradeep Simha Mar 28 '14 at 17:39
  • I tried both of the above and neither worked.... javac worked on the working machine but not the broken one. I added the classpath which was a good idea. But still no cigar. Other thoughts? I'm really stuck. – Dan Rasmuson Mar 28 '14 at 17:58
  • Is javac even installed on the second computer? – Hot Licks Mar 28 '14 at 18:01
  • Are both .class files in the same folder on both computers? Do they have any "package xxxxx;" heading? – user3407000 Mar 28 '14 at 18:04
  • 1
    What is the location in the error?? see this http://stackoverflow.com/questions/13537668/javac-cannot-find-symbol Use **javac PathToSourceFile/Test.java** and **javac PathToSourceFile/TestRun.java** – prem30488 Mar 28 '14 at 18:11
  • *How* is it not working? Is there any sort of error message? – tobias_k Mar 28 '14 at 18:18
  • 1
    use **javac -sourcepath src -d classes PathToSourceFile/Test.java** and **javac -sourcepath src -d classes PathToSourceFile/TestRun.java**... maybe this will work... otherwise at least display your error message here.. so we can understand – prem30488 Mar 28 '14 at 18:19
  • Sorry, but do you seriously need to run Java from the command line? Join the 21st century and start using eclipse or NetBeans. Unless you are ssh'ing into a machine or something and you absolutely have to run through the command line. – Jared Mar 28 '14 at 18:21
  • Thanks everyone for the help! As instructed above it was a problem with my path. A missing ';'. Thanks again everyone. – Dan Rasmuson Mar 31 '14 at 13:55

0 Answers0