| | |
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 10: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
| Thread Tools | Search this Thread |
911 actionlistener addressbook android api append applet application array arrays automation binary block bluetooth character class client code component consumer csv database desktop developmenthelp eclipse error fractal ftp game gameprogramming givemetehcodez graphics gui html ide image integer j2me j2seprojects japplet java javaarraylist javac javaee javaprojects jni jpanel julia lego linked linux list loops mac map method methods mobile netbeans newbie number objects online oriented panel printf problem program programming project projects properties recursion replaydirector reporting researchinmotion rotatetext rsa scanner se server set singleton sms sort sql string swing system test textfields threads time title tree tutorial-sample ubuntu update windows working






