More info about this strange compile error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tony Johansson

    #1

    More info about this strange compile error

    Hello!

    I get compile error when compiling using the command javac from the command
    terminal window(CMD).
    I have just two classes which are called HelloWorld.java and Slask.java.
    I have both classes in the directory called temp and I do cd temp to this
    directory.
    Then I do javac HelloWorld.java
    Now I get the compile error
    HelloWorld.java :9 cannot find symbol
    symbol : class Slask
    location: class HelloWorld
    Slask slask = new Slask(); //And the top sign is pointing at the first
    Slask

    HelloWorld.java :9 cannot find symbol
    symbol : class Slask
    location: class HelloWorld
    Slask slask = new Slask(); //And the top sign is pointing at the last
    Slask

    If I use for example the Blue J IDE than it works or if I put these two
    files in a project and compile with
    Microsoft visualStudio J# it also works. But why do I get compile error when
    using the javac from the terminal window(cmd)

    I have reinstalled the java development kit 1.5 but I still get the same
    compile errorr
    I use Microsoft proffessionel.
    Is it anyone out there that have a suggestion what I can do?

    import java.io.*;
    public class HelloWorld
    {
    private String out;
    public HelloWorld()
    {
    Slask slask = new Slask();
    out = "Hello world";
    }

    public void printHelloWorld ()
    { System.out.prin tln("skriver ut:" + out); }

    public static void main(String args[])
    {
    HelloWorld hw = new HelloWorld();
    hw.printHelloWo rld();
    }
    }

    import java.io.*;
    public class Slask
    {
    }

    //Tony




  • Jack Marsh

    #2
    Re: More info about this strange compile error


    "Tony Johansson" <johansson.ande rsson@telia.com > wrote in message
    news:Mn0Ve.3356 0$d5.188893@new sb.telia.net...[color=blue]
    > Hello!
    >
    > I get compile error when compiling using the command javac from the
    > command
    > terminal window(CMD).
    > I have just two classes which are called HelloWorld.java and Slask.java.
    > I have both classes in the directory called temp and I do cd temp to this
    > directory.
    > Then I do javac HelloWorld.java
    > Now I get the compile error
    > HelloWorld.java :9 cannot find symbol
    > symbol : class Slask
    > location: class HelloWorld
    > Slask slask = new Slask(); //And the top sign is pointing at the
    > first
    > Slask
    >
    > HelloWorld.java :9 cannot find symbol
    > symbol : class Slask
    > location: class HelloWorld
    > Slask slask = new Slask(); //And the top sign is pointing at the last
    > Slask
    >
    > If I use for example the Blue J IDE than it works or if I put these two
    > files in a project and compile with
    > Microsoft visualStudio J# it also works. But why do I get compile error
    > when
    > using the javac from the terminal window(cmd)
    >
    > I have reinstalled the java development kit 1.5 but I still get the same
    > compile errorr
    > I use Microsoft proffessionel.
    > Is it anyone out there that have a suggestion what I can do?
    >
    > import java.io.*;
    > public class HelloWorld
    > {
    > private String out;
    > public HelloWorld()
    > {
    > Slask slask = new Slask();
    > out = "Hello world";
    > }
    >
    > public void printHelloWorld ()
    > { System.out.prin tln("skriver ut:" + out); }
    >
    > public static void main(String args[])
    > {
    > HelloWorld hw = new HelloWorld();
    > hw.printHelloWo rld();
    > }
    > }
    >
    > import java.io.*;
    > public class Slask
    > {
    > }
    >
    > //Tony[/color]


    try telling the compiler where the classes are located

    javac -classpath . HelloWorld.java
    javac -classpath . Slask.java

    note that . (dot) is the current directory

    then to run the rusult

    java -cp . HelloWorld



    Comment

    • Terry Milan

      #3
      Re: More info about this strange compile error

      Try running javac *.java in your temp directory. Should compile both units
      and reconcile.

      "Tony Johansson" <johansson.ande rsson@telia.com > wrote in message
      news:Mn0Ve.3356 0$d5.188893@new sb.telia.net...[color=blue]
      > Hello!
      >
      > I get compile error when compiling using the command javac from the[/color]
      command[color=blue]
      > terminal window(CMD).
      > I have just two classes which are called HelloWorld.java and Slask.java.
      > I have both classes in the directory called temp and I do cd temp to this
      > directory.
      > Then I do javac HelloWorld.java
      > Now I get the compile error
      > HelloWorld.java :9 cannot find symbol
      > symbol : class Slask
      > location: class HelloWorld
      > Slask slask = new Slask(); //And the top sign is pointing at the[/color]
      first[color=blue]
      > Slask
      >
      > HelloWorld.java :9 cannot find symbol
      > symbol : class Slask
      > location: class HelloWorld
      > Slask slask = new Slask(); //And the top sign is pointing at the last
      > Slask
      >
      > If I use for example the Blue J IDE than it works or if I put these two
      > files in a project and compile with
      > Microsoft visualStudio J# it also works. But why do I get compile error[/color]
      when[color=blue]
      > using the javac from the terminal window(cmd)
      >
      > I have reinstalled the java development kit 1.5 but I still get the same
      > compile errorr
      > I use Microsoft proffessionel.
      > Is it anyone out there that have a suggestion what I can do?
      >
      > import java.io.*;
      > public class HelloWorld
      > {
      > private String out;
      > public HelloWorld()
      > {
      > Slask slask = new Slask();
      > out = "Hello world";
      > }
      >
      > public void printHelloWorld ()
      > { System.out.prin tln("skriver ut:" + out); }
      >
      > public static void main(String args[])
      > {
      > HelloWorld hw = new HelloWorld();
      > hw.printHelloWo rld();
      > }
      > }
      >
      > import java.io.*;
      > public class Slask
      > {
      > }
      >
      > //Tony
      >
      >
      >
      >[/color]


      Comment

      Working...