— Scott McNealy, Sun Microsystems Chairman, President and ceo



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

590
 
chapter 17
%cd MyProject/classes
%java com.headfi rstjava.PackageExercise
%cd MyProject/source
%javac -d ../classes com/headfi rstjava/PackageExercise.java
Compiling with the 
-d
(directory) fl ag
tells the compiler to put the 
compiled code (class files) 
into the classes directory, 
within the right package 
structure!!
Yes, it knows.
Now you have to specify 
the PATH to get to the 
actual source file. 
To compile all the .java fi les in the com.headfi rstjava 
package, use:
Running your code
run your program from 
the ‘classes’ directory. 
%javac -d ../classes com/headfi rstjava/*.java
Compiling and running with packages
When your class is in a package, it’s a little trickier to compile and 
run. The main issue is that both the compiler and JVM have to be 
capable of fi nding your class and all of the other classes it uses. 
For the classes in the core API, that’s never a problem. Java always 
knows where its own stuff is. But for your classes, the solution 
of compiling from the same directory where the source fi les are 
simply won’t work (or at least not reliably). We guarantee, though, 
that if you follow the structure we describe on this page, you’ll be 
successful. There are other ways to do it, but this is the one we’ve 
found the most reliable and the easiest to stick to.
MyProject
source
classes
101101 
10 110 1 
0 11 0 
001 10 
001 01 
PackageExercise.class
com
headfirstjava
com
headfirstjava
 
Lorper 
iure 
eugue 
tat vero 

Download 40,57 Mb.

Do'stlaringiz bilan baham:
1   ...   540   541   542   543   544   545   546   547   ...   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