classpath errors

Reply

Join Date: Jun 2006
Posts: 8
Reputation: gerik is an unknown quantity at this point 
Solved Threads: 0
gerik gerik is offline Offline
Newbie Poster

classpath errors

 
0
  #1
Oct 29th, 2007
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?
Last edited by gerik; Oct 29th, 2007 at 10:32 am.
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,438
Reputation: Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of 
Solved Threads: 509
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: classpath errors

 
0
  #2
Oct 29th, 2007
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 ].
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 213
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: classpath errors

 
0
  #3
Oct 29th, 2007
you need to add the current directory to the classpath as well.
It's not there by default on most modern operating systems for security reasons.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 8
Reputation: gerik is an unknown quantity at this point 
Solved Threads: 0
gerik gerik is offline Offline
Newbie Poster

Re: classpath errors

 
0
  #4
Oct 29th, 2007
How do you add the current directory to the classpath?
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,438
Reputation: Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of 
Solved Threads: 509
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: classpath errors

 
0
  #5
Oct 29th, 2007
javac -cp .\;.\classes Koetesti.java
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC