| | |
classpath errors
![]() |
•
•
Join Date: Jun 2006
Posts: 8
Reputation:
Solved Threads: 0
I've been trying to work out this error with packages, changing the classpath name in a number of different ways (using set, declaring it in the javac command), but I always get the following errors when I try to compile the following code:
import kalut.*;
import java.lang.Math.*;
public class Koetesti {
public static void main(String[] args) {
Koe a = new Koe();
a.x = 5;
System.out.println("a.x: " + a.x);
}
}
ku-hupnet193-75:~/lahdekoodit/javaohj dshaw$ javac Koetesti.java
Koetesti.java:1: package kalut does not exist
import kalut.*;
^
Koetesti.java:6: cannot access Koe
bad class file: ./Koe.java
file does not contain class Koe
Please remove or make sure it appears in the correct subdirectory of the classpath.
Koe a = new Koe();
^
2 errors
It seems as if the it's looking for the class file in the current direction, despite the fact that I have the classpath set to ./classes (more specifically, /Users/dshaw/lahdekoodit/javaohj/classes). It almost seems like I have some stupid error like incorrect case but I don't, still nothing helps. What am I not doing?
Edit: I realised that it's the .java file, not the .class file, that the compiler uses for packages. I also noticed that the compiler wants the package files to be in a directory that is named after the package, in my case, in the directory "kalut". But for some reason it only works when folder "kalut" is in the current working directory, not the "./classes" directory as I have the classpath defined. Any reasons for this?
import kalut.*;
import java.lang.Math.*;
public class Koetesti {
public static void main(String[] args) {
Koe a = new Koe();
a.x = 5;
System.out.println("a.x: " + a.x);
}
}
ku-hupnet193-75:~/lahdekoodit/javaohj dshaw$ javac Koetesti.java
Koetesti.java:1: package kalut does not exist
import kalut.*;
^
Koetesti.java:6: cannot access Koe
bad class file: ./Koe.java
file does not contain class Koe
Please remove or make sure it appears in the correct subdirectory of the classpath.
Koe a = new Koe();
^
2 errors
It seems as if the it's looking for the class file in the current direction, despite the fact that I have the classpath set to ./classes (more specifically, /Users/dshaw/lahdekoodit/javaohj/classes). It almost seems like I have some stupid error like incorrect case but I don't, still nothing helps. What am I not doing?
Edit: I realised that it's the .java file, not the .class file, that the compiler uses for packages. I also noticed that the compiler wants the package files to be in a directory that is named after the package, in my case, in the directory "kalut". But for some reason it only works when folder "kalut" is in the current working directory, not the "./classes" directory as I have the classpath defined. Any reasons for this?
Last edited by gerik; Oct 29th, 2007 at 9:32 am.
You may have not set the environment variable correctly. Check the manual pages for your OS
javac(1) - Manual page [ Solaris™ Operating System | Microsoft Windows ].
javac(1) - Manual page [ Solaris™ Operating System | Microsoft Windows ].
![]() |
Similar Threads
- classpath (Java)
- Simple Programming Errors (Computer Science)
- confused with errors in c++ (C++)
- Loader.EXE and IEDLL.EXE errors (Web Browsers)
- Errors during scandisk (Windows 95 / 98 / Me)
- Upgrading Xp Home to Pro - ERRORS! (Windows NT / 2000 / XP)
- strange annoying errors (Windows NT / 2000 / XP)
- w2k server errors (Windows NT / 2000 / XP)
- Two Problems- "Page Cannot Be Displayed" Errors, Z (Windows NT / 2000 / XP)
Other Threads in the Java Forum
- Previous Thread: Learning Tools
- Next Thread: Clear the console screen
Views: 1021 | Replies: 4
| Thread Tools | Search this Thread |
Tag cloud for Java
actionlistener add android applet arguments array arraylist arrays binary bluetooth c++ chat class classes client code compiler component convert converter coordinates data database db design detection draw eclipse error event exception file forloop fractal givemetehcodez graphics gridlayout gui helpwithhomework homeworkassignment html ide image images input integer j2me java jframe jmf jni jpanel jtextfield key lazy linked linked-list list loop main method methods mobile netbeans newbie node number object oracle os pattern phone pixel printing problem program programming read remote remove return robot scanner server set size sms sort sql string swing system test text text-file thread transfer tree user web






