Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (576)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  javac question  (Read 1695 times)
0 Members and 1 Guest are viewing this topic.
Offline pepsi

Senior Newbie




Java games rock!


« Posted 2004-08-19 08: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)
Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Reply #1 - Posted 2004-08-19 10: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...
Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Reply #2 - Posted 2004-08-19 10: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!
Legends of Yore - The Casual Retro Roguelike
Offline woogley
« Reply #3 - Posted 2004-08-19 14: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...  :-/
Offline oNyx

JGO Coder


Medals: 2


pixels! :x


« Reply #4 - Posted 2004-08-19 16:59:56 »

Quote
[...]
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 Huh

弾幕 ☆ @mahonnaiseblog
Offline woogley
« Reply #5 - Posted 2004-08-19 18:46:03 »

Quote


I'd never had to do that Huh


I hafta do it with my 1.4.0 compiler Sad
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...
Offline oNyx

JGO Coder


Medals: 2


pixels! :x


« Reply #6 - Posted 2004-08-19 19: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.

弾幕 ☆ @mahonnaiseblog
Offline woogley
« Reply #7 - Posted 2004-08-19 19:31:45 »

that's probably true, I just dont usually mess with packages if all the classes are in one dir Roll Eyes
Offline oNyx

JGO Coder


Medals: 2


pixels! :x


« Reply #8 - Posted 2004-08-19 19:38:54 »

C:\Java\JunkBox>cd rpg
C:\Java\JunkBox\rpg>javac RPG.java

should do the trick then Wink

弾幕 ☆ @mahonnaiseblog
Offline woogley
« Reply #9 - Posted 2004-08-19 19: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 Tongue
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline oNyx

JGO Coder


Medals: 2


pixels! :x


« Reply #10 - Posted 2004-08-19 19:52:41 »

Hehe. Sorry Tongue

I just enjoy being silly a bit too much Wink

弾幕 ☆ @mahonnaiseblog
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Longarmx (38 views)
2014-10-17 03:59:02

Norakomi (28 views)
2014-10-16 15:22:06

Norakomi (24 views)
2014-10-16 15:20:20

lcass (28 views)
2014-10-15 16:18:58

TehJavaDev (53 views)
2014-10-14 00:39:48

TehJavaDev (54 views)
2014-10-14 00:35:47

TehJavaDev (43 views)
2014-10-14 00:32:37

BurntPizza (64 views)
2014-10-11 23:24:42

BurntPizza (36 views)
2014-10-11 23:10:45

BurntPizza (78 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!