— Scott McNealy, Sun Microsystems Chairman, President and ceo


directory inside named “foo”



Download 40,57 Mb.
Pdf ko'rish
bet546/555
Sana26.05.2022
Hajmi40,57 Mb.
#609235
1   ...   542   543   544   545   546   547   548   549   ...   555
Bog'liq
Head First Java (Kathy Sierra, Bert Bates) (z-lib.org)

directory inside named “foo”. Only 
then will the JVM accept that its 
found the correct Book class. If it 
finds a Book class anywhere else, 
it assumes the class isn’t in the 
right structure, even if it is! The 
JVM won’t for example, look back 
up the directory tree to say, “Oh, I 
can see that above us is a directory 
named com, so this must be the 
right package...”
The -d flag is even cooler than we said
Compiling with the 
-d 
fl ag is wonderful because not only does it 
let you send your compiled class fi les into a directory other than 
the one where the source fi le is, but it also knows to put the class 
into the correct directory structure for the package the class is in.
But it gets even better!
Let’s say that you have a nice 
directory structure all set up for your 
source code. But you haven’t set 
up a matching directory structure 
for your classes directory. Not a 
problem! Compiling with 
-d tells the compiler to not 
just put your classes into 
the 
correct directory tree, but to 
build 
the directories if they don’t 
exist.
MyProject
source
classes
com
headfirstjava
 
Lorper 
iure 
eugue 
tat vero 
conse 
euguero-
PackageExercise.java
If the package directory structure 
doesn’t exist under the ‘classes’ 
directory, the compiler will build the 
directories if you use the -d flag.
So you don’t actually have to 
physically create the directories under 
the ‘classes’ root directory. And in 
fact, if you let the compiler do it 
there’s no chance of a typo. 
The 
-d
fl ag tells the compiler, 
“Put the class into its package 
directory structure, using the 
class specifi ed after the 
-d
as 
the root directory. But... if the 
directories aren’t there, create 
them fi rst and 
then put the class 
in the right place!”



Download 40,57 Mb.

Do'stlaringiz bilan baham:
1   ...   542   543   544   545   546   547   548   549   ...   555




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish