By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,223 Members | 1,371 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,223 IT Pros & Developers. It's quick & easy.

beginners Compile error cannot resolve symbol

P: n/a
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.println("skriver ut:" + out);
}

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

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

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

//Tony
Sep 11 '05 #1
Share this Question
Share on Google+
1 Reply


P: 18
Try:

Expand|Select|Wrap|Line Numbers
  1. 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:

Expand|Select|Wrap|Line Numbers
  1. javac -cp .;c:\my\dir\here\;c:\some\other\path;c:\path\to\jarFile.jar *.java
Oct 5 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.