Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Splitting Source and Class Code

 
Ranch Hand
Posts: 435
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just wondering id someone could help me with sourcepaths
I have the directory structure
classes
src
sampleproject
db
and am trying to split the source and class files
If I use
javac -d classes src/sampleproject/db/*.java
the files are compiled to the classes directory but under src.
I tried
javac -d classes -sourcepath src sampleproject/db/*.java
which I expected to work but my java files could not be found.
Also tried some varations with classpath but got lost.
Any ideas
Could anyone point out a fundemental error I'm making
Cheers Tony
 
Tony Collins
Ranch Hand
Posts: 435
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just clear up the structure of my directories structure
src---->sampleproject---->db contains java source
classes->
 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try this:
javac -sourcepath src/sampleproject/db/ -d classes *.java
Make sure that the directory classes exists and that both source and class directories are on the same mounted root.
 
Tony Collins
Ranch Hand
Posts: 435
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No Luck with that. Still get error: cannot read *.java
The files are there and I'm calling javac from the directory above classes and src.
Does javac work in some strange way or am I missing something?
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm having the same problem. If I use a sourcepath javac doesn't seem to be able to locate the source files. Maybe someone else knows something about this?
 
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Tony,
i tried following,
i have a dir hierarchy as,
HOME/test1/test2/test.java
HOME/test3
i write following command,
javac -d test3 test1/test2/*.java
and it creats test.class in test3 directory...
thats what u want right?
also, u r not using any Packages right? because if u have package src for each .java file then it WILL create the src directory in the classes and then put all class files there...
regards
maulin
 
Tony Collins
Ranch Hand
Posts: 435
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Cheers my packaging is the problem
My package was src.sampleproject.db
hence the confusion
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic