A cikin wannan labarin, za mu mai da hankali kan shigar da aikace-aikacen Java akan yanayin Linux. Za mu shiga cikin nitty-gritty na tsarin shigarwa, tattaunawa akan mahimman ษakunan karatu, ayyuka, da sauran abubuwa don sa aikace-aikacen Java ษinku ya yi aiki ba tare da matsala ba akan Linux.
** Sanya Java akan Linux ***
Kafin mu ci gaba da mafita, yana da mahimmanci a sami kyakkyawar fahimta game da Java da kuma dacewarta a cikin ci gaban duniya. Java, yaren shirye-shiryen da ke da alaฦa da abu, ana amfani da shi don ฦirฦirar aikace-aikacen da za su iya gudana akan dandamali da yawa, gami da Linux, macOS, da Windows. Ya shahara sosai saboda iyawar sa, sauฦin amfani, da ษimbin ษakunan karatu da APIs.
Ana shigar da Kit ษin Ci gaban Java (JDK)
Don fara shigar da Java akan Linux, yana da mahimmanci a fara shigar da Kit ษin Ci gaban Java (JDK). JDK ya zo tare da Java Runtime Environment (JRE), wanda ya zama dole don aiwatar da shirye-shiryen Java akan tsarin Linux ษin ku. Matakan da ke ฦasa dalla-dalla yadda ake cim ma wannan aikin:
- Sabunta jerin fakitin Linux ษinku ta hanyar gudanar da umarni mai zuwa a cikin tasha:
sudo apt-get update
- Shigar da kunshin OpenJDK tare da umarni mai zuwa:
sudo apt-get install openjdk-11-jdk
- Bayan nasarar shigar da kunshin OpenJDK, tabbatar da shigarwa ta hanyar aiwatar da umarnin:
java -version
Idan shigarwa ya yi nasara, ya kamata ku ga bayani game da sigar Java da aka shigar.
Saita Canjin Muhalli
Bayan shigar da JDK, yana da mahimmanci don saita masu canjin yanayi don haษaka amfani da tsarin yanayin ci gaban ku.
- HANYA: Wannan madaidaicin ya ฦunshi jerin kundayen adireshi waษanda tsarin ke neman shirye-shirye masu aiwatarwa. ฦara JDK zuwa wannan jeri yana tabbatar da cewa an gane Java kuma ana samun dama daga kowane kundin adireshi akan tsarin Linux ษin ku.
- Rariya Wannan madaidaicin yana wakiltar jagorar shigarwa na JDK. Sau da yawa wasu aikace-aikacen tushen Java suna amfani da shi don gano wurin shigarwar JDK.
Domin saita waษannan masu canjin yanayi, bi matakan da ke ฦasa:
1. Bude fayil ษin /etc/environment a cikin editan rubutu tare da gata na gudanarwa. Misali, zaku iya amfani da nano ta hanyar buga:
sudo nano /etc/environment
2. ฦara layin masu zuwa zuwa ฦarshen fayil ษin, maye gurbin "/ naku / java / hanya" tare da ainihin hanyar shigarwa na JDK:
JAVA_HOME="/your/java/path" export JAVA_HOME PATH=$JAVA_HOME/bin:$PATH export PATH
3. Ajiye fayil ษin kuma fita editan rubutu.
4. Sake loda masu canjin yanayi ta hanyar aiwatar da umarni:
source /etc/environment
Yanzu, kun yi nasarar shigar da sigar Java da ake buฦata kuma kun daidaita masu canjin yanayi.
Fahimtar Laburaren Java da Ayyuka
Laburaren Java da ayyuka suna taka muhimmiyar rawa wajen sauฦaฦe tsarin ci gaba. Babban ษakin karatu da wadatar ayyuka yana ba masu haษakawa damar yin takamaiman ayyuka yadda ya kamata da inganci, ba tare da buฦatar rubuta lambar daga karce ba.
Binciko Standard Library na Java
Ma'auni na ษakin karatu na Java, wanda kuma aka sani da Java API (Application Programming Interface), ya ฦunshi yawancin azuzuwan da aka riga aka gina da kuma hanyoyin da ke da amfani ga ayyuka daban-daban na shirye-shirye. An tsara su cikin fakiti, waษanda ke taimakawa rarraba azuzuwan da ke da alaฦa da musaya zuwa sararin suna ษaya.
Wasu fakitin da aka saba amfani da su sun haษa da:
- java.lang: Wannan fakitin yana ba da mahimman azuzuwan da musaya masu mahimmanci don yaren shirye-shiryen Java. Ya haษa da azuzuwan kamar Abu, String, Math, da System.
- java.util: Wannan fakitin yana ba da tarin azuzuwan kayan aiki, gami da tsarin bayanai (ArrayList, HashMap, da sauransu), abubuwan amfani na kwanan wata da lokaci, da tsara lambar bazuwar.
- java.io: Wannan fakitin ya ฦunshi azuzuwan da ake buฦata don ayyukan shigarwa-fitarwa, kamar karantawa da rubutu zuwa fayiloli, na'ura wasan bidiyo, da sauran rafukan bayanai.
- java.net: Wannan kunshin yana ba da azuzuwan don shirye-shiryen cibiyar sadarwa, kamar aiwatar da soket ษin TCP/IP da aiki tare da URLs.
A ฦarshe, ci gaban Java akan dandamali na Linux yana buฦatar cikakken sani game da tsarin shigarwa, daidaita yanayin canjin yanayi, da fahimtar ษakunan karatu da ayyuka na Java. Tare da JDK da ya dace da kuma saita sauye-sauyen yanayi yadda ya kamata, masu haษakawa na iya amfani da cikakken damar APIs na Java don ฦirฦirar aikace-aikace masu ฦarfi da inganci.