pepsi
Senior Newbie 
Java games rock!
|
 |
«
Posted
2004-08-19 10:29:27 » |
|
Look at this.
c:\javactest contains only a directory called "src"
c:\javactest\src contains only a valid Test.java source file.
Now, why can't I compile with
c:\javactest>javac -sourcepath src Test.java
(It works with c:\javatest\source>javac Test.java)
|
|
|
|
|
blahblahblahh
|
 |
«
Reply #1 - Posted
2004-08-19 12:17:58 » |
|
Aha! I logged a bug against this with Sun, and they accepted it IIRC only to tell me I was (basically) being annoying (and I kind of see their point) - IIRC (I'll need to check what happened, actually).
My bug/RFE basically goes:
"sourcepath is one of the worst named flags ever: it doesn't mean what it says, it actually means something different.
Worse, the documentation that comes with java 1.4.x provides a description that is incorrect - it describes something different to what is implemented because it omits a crucial sub-clause.
Please either change the docs, or even better rename the flag and also add a flag that really does mean "-sourcepath" because I actually need one!"
(My reasons for "needing" this flag are unusual, and to do with running javac in an environment where it is a *very* bad thing to list the contents of the current working directory, which - unfortunately - javac is hard-coded to do in it's search for sources; I wanted it to use sourcepath to force it to look in a sub-dir ONLY, and not list the CWD, which incurs a massive performance penalty)
If you want to know more, I suggest you get a JDC ID (sorry - I hate the fact you need to do this, but it is free), go to Sun's Bug Parade (google for it), do a search for bugs to do with sourcepath, and read the bug and the comments.
|
malloc will be first against the wall when the revolution comes...
|
|
|
blahblahblahh
|
 |
«
Reply #2 - Posted
2004-08-19 12:20:41 » |
|
PS: Sorry, the short answer (appropriate for a newbie) is:
Sourcepath does NOT mean sourcepath.
It actually means (this is/was not documented by Sun) "the path where source files are loaded from ONLY when they are needed for recompilation of external classes referenced by the main source (which, because sourcepath doesn't do what you think it does, can ONLY be compiled from the current working directory) which javac cannot find class files for, and so has decided to automatically compile from source in order to work out if the source code you are asking it to compile actually compiles". Phew.
In other words, the flag ought to be:
-secondarysourcepath
or
-externalsourcepath
or something like that.
|
malloc will be first against the wall when the revolution comes...
|
|
|
Games published by our own members! Check 'em out!
|
|
woogley
|
 |
«
Reply #3 - Posted
2004-08-19 16:56:05 » |
|
wow, blah3 is right.. that is really stupid...
anyway, if you still want to compile sources that arent in your current directory, you can do this:
c:\javactest>javac src\Test.java
which is especially helpful if you're compiling entire packages:
c:\javactest>javac src\*.java
only problem with the first way right there is if that Test.java is using another class located in that directory, it won't compile unless you do:
c:\javactest>javac -classpath src src\Test.java
...that's another annoying thing about javac. Unlike its little brother java.exe, it doesn't have the handy -cp flag... :-/
|
|
|
|
|
oNyx
|
 |
«
Reply #4 - Posted
2004-08-19 18:59:56 » |
|
[...] only problem with the first way right there is if that Test.java is using another class located in that directory, it won't compile unless you do:
c:\javactest>javac -classpath src src\Test.java [...] I'd never had to do that 
|
|
|
|
woogley
|
 |
«
Reply #5 - Posted
2004-08-19 20:46:03 » |
|
I'd never had to do that  I hafta do it with my 1.4.0 compiler  Observe: 1 2 3 4 5 6 7 8 9 10
| C:\Java\JunkBox>javac rpg\RPG.java rpg\RPG.java:6: cannot resolve symbol symbol : class Test location: class RPG Test test; ^ rpg\RPG.java:7: cannot resolve symbol symbol : class Surface location: class RPG Surface surface; |
but... with -classpath: 1 2 3
| C:\Java\JunkBox>javac -classpath rpg rpg\RPG.java
C:\Java\JunkBox> |
strange...
|
|
|
|
|
oNyx
|
 |
«
Reply #6 - Posted
2004-08-19 21:11:38 » |
|
Ah... uhm... it's because it doesn't match the packaging, does it?
So if Test would be in the package rgb, javac would find it.
|
|
|
|
woogley
|
 |
«
Reply #7 - Posted
2004-08-19 21:31:45 » |
|
that's probably true, I just dont usually mess with packages if all the classes are in one dir 
|
|
|
|
|
oNyx
|
 |
«
Reply #8 - Posted
2004-08-19 21:38:54 » |
|
C:\Java\JunkBox>cd rpg C:\Java\JunkBox\rpg>javac RPG.java should do the trick then 
|
|
|
|
woogley
|
 |
«
Reply #9 - Posted
2004-08-19 21:43:07 » |
|
lol well YEAH we all know that, the point was to compile from a different directory than the classes like the OP wanted 
|
|
|
|
|
Games published by our own members! Check 'em out!
|
|
oNyx
|
 |
«
Reply #10 - Posted
2004-08-19 21:52:41 » |
|
Hehe. Sorry  I just enjoy being silly a bit too much 
|
|
|
|
|