beginners Compile error cannot resolve symbol

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

    beginners Compile error cannot resolve symbol

    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 :8 cannot resolve symbol
    symbol : class Slask
    location: class helloWorld
    Slask slask = new Slask(); //And the top sign is pointing at the first
    Slask

    HelloWorld.java :8 cannot resolve 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)

    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
    {
    private String out;
    public Slask()
    {
    out = "slask";
    }

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

    //Tony


  • UniDyne
    New Member
    • Oct 2005
    • 18

    #2
    Try:

    Code:
    javac -cp . *.java
    This should compile. The trick is to tell Java what the classpath is. "-cp ." tells Java that the classpath is the current directory. If you wanted to include other directories, you would list them as well, separated by semicolons:

    Code:
    javac -cp .;c:\my\dir\here\;c:\some\other\path;c:\path\to\jarFile.jar *.java

    Comment

    Working...