Thaum feem ntau qhov kev txhim kho ib puag ncig ib puag ncig (IDEs) tso cai rau koj los sau thiab ua haujlwm cov haujlwm ncaj qha, koj tseem tuaj yeem suav sau thiab ntsuas cov phiaj xwm los ntawm kab hais kom ua. Cov kab hais kom ua interface ntawm Windows yog hu ua Command Prompt, thaum ntawm Mac, tib lub interface hu ua Terminal. Txawm li cas los xij, cov txheej txheem rau suav thiab ua haujlwm Java cov haujlwm ntawm kab hais kom ua ntawm ob lub tshuab ua haujlwm yog qhov tseem ceeb tib yam.
Kauj ruam
Txoj Kev 1 ntawm 2: Ua Ke thiab Khiav Haujlwm
Kauj Ruam 1. Tom qab sau cov cai nrog cov ntawv sau zoo li Notepad, txuag qhov program nrog.java txuas ntxiv
Koj tuaj yeem sau npe cov ntaub ntawv raws li koj xav tau. Piv txwv li, hauv phau ntawv qhia no, cov npe siv uas siv yog "filename".
- Thaum khaws cov ntaub ntawv, tsis txhob hnov qab sau qhov ".java" txuas ntxiv tom qab lub npe cov ntaub ntawv, thiab xaiv Txhua Cov Ntaub Ntawv xaiv hauv ntu txuas ntxiv.
- Paub qhov twg los khaws cov ntawv uas muaj cov program code.
- Yog tias koj tsis nkag siab Java, nyeem cov lus qhia hauv is taws nem. Thaum kawm, sim ua haujlwm sib txawv ntawm cov haujlwm.
Kauj Ruam 2. Qhib kab hais kom ua interface ntawm koj lub system
Txoj hauv kev qhib qhov kev sib txawv no txawv nyob ntawm seb koj puas siv Windows lossis Mac.
- Windows: Nias Tsev, tom qab ntawd nkag mus ua cmd hauv Run dialog box. Tom qab ntawd, nyem Enter. Qhov Command Prompt window yuav qhib.
- Mac: hauv Finder, nyem rau Go tab, tom qab ntawd xaiv Cov Ntawv Thov> Cov Khoom Siv. Hauv Utilities nplaub tshev, xaiv Terminal.
Kauj Ruam 3. Txheeb xyuas yog tias Java tau teeb tsa hauv computer nrog cov lus txib
java -version
.
Yog tias Java tau teeb tsa lawm, koj yuav pom Java version ntawm lub vijtsam.
Yog tias Java tsis tau teeb tsa, rub tawm Java Development Kit dawb los ntawm
Kauj Ruam 4. Mus rau phau ntawv teev npe qhov chaw uas koj tau khaws cov ntaub ntawv program
Siv "cd" hais kom ua, ua raws li cov npe npe.
-
Piv txwv li, yog hais tias kab hais kom ua interface nyob hauv daim nplaub tshev
C: / Users / Ayu Rosmalina / Project
thiab koj khaws cov cai hauv daim nplaub tshev
C: / Users / Ayu Rosmalina / Project / Fake Address
ntxig
cd Chaw Nyob Cuav
- , thiab nias Enter.
-
Koj tuaj yeem saib cov ntsiab lus ntawm daim nplaub tshev nrog cov lus txib
ua dir
- . Tom qab nkag mus rau qhov hais kom ua, nyem Enter.
Kauj Ruam 5. Tom qab mus rau daim nplaub tshev uas koj tau khaws cov program, suav nws
Nkag mus hais kom ua
javac filename.java
thiab nias Enter.
- Kev ua yuam kev lossis yuam kev thaum sau ua ke yuav tshwm nyob rau hauv kab hais kom ua qhov rai.
- Nyeem cov lus qhia hauv is taws nem kom paub daws teeb meem yuam kev hauv Java.
Kauj Ruam 6. Khiav qhov program los ntawm kev nkag mus rau qhov hais kom ua
java npe
.
Tom qab ntawd, nyem Enter. Hloov "filename" nrog lub npe ntawm koj li Java program.
Tom qab nias Enter, koj qhov program yuav khiav. Nyeem cov kauj ruam tom ntej los daws qhov tsis raug uas yuav tshwm sim thaum ua haujlwm
Txoj Kev 2 ntawm 2: Teeb meem
Kauj Ruam 1. Teeb PATH yog tias koj tab tom yuav ua txoj haujlwm nyuaj uas tso cov ntaub ntawv rau hauv ntau phau ntawv teev npe
Yog tias koj tsuas yog ua haujlwm yooj yim xwb, thiab txhua daim ntawv thov kev pab cuam nyob hauv tib lub nplaub tshev, koj tsis tas yuav ua cov kauj ruam no.
-
Windows: Nkag mus hais kom ua
java -version
thiab nias Enter. Nco tseg ntawm Java version uas tshwm ntawm qhov screen. Tom qab ntawd, nkag mus rau qhov hais kom ua
teeb txoj hauv kev =%txoj kev%; C: / Cov Ntaub Ntawv Cov Ntaub Ntawv Java Java jdk1.5.0_09 / bin
thiab hloov jdk1.5.0_09 nrog java version koj tau sau tseg ua ntej. Tom qab ntawd, nyem Enter.
Xyuas kom tseeb tias koj taw tes kab lus txib rau daim ntawv thov khaws cia ua ntej khiav cov lus txib saum toj no
-
Mac: nkag mus hais kom ua
/usr/libexec/java_home -v 1.7
thiab nias Enter. Tom qab ntawd, nkag mus rau qhov hais kom ua
echo xa tawm "JAVA_HOME = / $ (/usr/libexec/java_home)" >> ~/.bash_profile
- , nias Enter, thiab rov pib dua Terminal.