အခြေခံ ကွန်ပျူတာပရိုဂရမ် ရေးသားနည်း- Installing and Configuring JDK
Java ပရိုဂရမ် တစ်ပုဒ်ကို အောက်ဖော်ပြပါ အချက်သုံးချက်နဲ့ ဖန်တီးရေးသား အသုံးပြုနိုင်ပါတယ်။
Create
Compile
Execute/Run
Creating a Java file
Java ပရိုဂရမ် တစ်ပုဒ်ကို ဘယ် Text Editor မှာ မဆို အလွယ်တကူ Create လုပ်နိုင်ပါတယ်။
Windows အသုံးပြုသူများအနေနဲ့ (Notepad/Notepad++/Textpad/Eclipse) အစရှိတဲ့ Text Editor တွေကို အသုံးပြုနိုင်ပါတယ်။ Mac အသုံးပြုသူများ (Sublime Text/Eclipse) ကို အသုံးပြုနိုင်ပြီး Linux အသုံးပြုသူများ Vi ကို အသုံးပြုနိုင်ပါတယ်။
အထက်ဖော်ပြပါ Text Editor များ မိမိတို့ ကွန်ပျူတာတွင် မရှိသေးလျှင် မိမိတို့ရဲ့ Operating System အလိုက် download လုပ်ပြီး install လုပ်နိုင်ပါသည်။
Notepad++ : https://notepad-plus-plus.org/downloads/
Textpad : https://www.textpad.com/download
Eclipse : https://www.eclipse.org/downloads/
Compiling and executing a Java file
Text Editor မှာ Create လုပ်ထားတဲ့ java ပရိုဂရမ်တစ်ပုဒ်ကို Execute မလုပ်ခင် Compile အရင် လုပ်ရပါတယ်။ ဂျာဗားပရိုဂရမ်တွေကို Compile လုပ်ဖို့ JDK လို့ ခေါ်တဲ့ Java Development Kit လိုအပ်ပါတယ်။ JDK ထဲမှာ Java နဲ့ Software တွေ ရေးသားဖန်တီးရာမှာ လိုအပ်တဲ့ အခြေခံ Tools တွေ ပါဝင်ပါတယ်။
Compile လုပ်ပြီးသွားရင် bytecode သို့မဟုတ် class file ကို Execute လုပ်ဖို့ JRE လို့ ခေါ်တဲ့ Java Runtime Environment လိုအပ်ပါတယ်။ JRE ထဲမှာ JVM လို့ ခေါ်တဲ့ Java Virtual Machine ပါဝင်ပြီး bytecode တွေကို အဲ့ဒီ JVM က Execute လုပ်ပေးပါတယ်။
JRE ပါဝင်ပြီးသားဖြစ်တဲ့ JDK ကို မိမိတို့ရဲ့ Operating System(Windows/Mac/Linux) အမျိူးအစားအလိုက် ဒီရဲ့လင့်ကနေ Java SE Development Kit 8 (JDK8) download လုပ်ပြီး install လုပ်နိုင်ပါတယ်။ ဒီရဲ့ သင်ခန်းစာမှာ JDK8 (version 8) ကို ဉပမာ အနေနဲ့ ဖော်ပြထားပါတယ်။
Installing and Configuring Java Development Kit
မိမိတို့ရဲ့ ကွန်ပျူတာမှာ JDK ကို install လုပ်ပြီးသွားရင် Java နဲ့ Software တွေ ရေးသားဖန်တီးနိုင်ဖို့ နဲ့ ရေးသားထားပြီးတဲ့ ဂျဗားပရိုဂရမ်တွေကို Compile နဲ့ Execute လုပ်နိုင်ဖို့ Configure လုပ်ပေးရပါတယ်။
Setting Temporary Path In Windows
မိမိတို့ရဲ့ ကွန်ပျူတာမှာ JDK ကို install လုပ်ထားတဲ့ path သို့မဟုတ် location နဲ့ version အမျိုးအစား အလိုက် ယာယီ temporary path ကို အောက်ဖော်ပြပါ ဉပမာအတိုင်း Windows Command Prompt မှာ ပေးနိုင်ပါတယ်။
set path = C:\Program Files\Java\jdk1.8.0_121\bin\
Setting Permanent Path In Windows
Temporary path ဟာ Windows Command Prompt ကို ပိတ်လိုက်တာနဲ့ ပျက်သွားပါတယ်။
Java Path ကို အမြဲတမ်း Permanent Path အနေနဲ့ အောက်ပါအတိုင်း ပေးလို့ ရပါတယ်။ Windows version အလိုက် အနည်းငယ် ကွာခြားမှု ရှိနိုင်ပါတယ်။
Windows 10 and Windows 8
In Search, search for and then select: System (Control Panel)
Click the Advanced system settings link.
Click Environment Variables. In the section System Variables find the PATH environment variable and select it. Click Edit. If the PATH environment variable does not exist, click New.
In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. Click OK. Close all remaining windows by clicking OK.
Reopen Command prompt window, and run your java code.
Windows 7
From the desktop, right click the Computer icon.
Choose Properties from the context menu.
Click the Advanced system settings link.
Click Environment Variables. In the section System Variables find the PATH environment variable and select it. Click Edit. If the PATH environment variable does not exist, click New.
In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. Click OK. Close all remaining windows by clicking OK.
Reopen Command prompt window, and run your java code.
Windows Vista
From the desktop, right click the My Computer icon.
Choose Properties from the context menu.
Click the Advanced tab (Advanced system settings link in Vista).
Click Environment Variables. In the section System Variables find the PATH environment variable and select it. Click Edit. If the PATH environment variable does not exist, click New.
In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. Click OK. Close all remaining windows by clicking OK.
Reopen Command prompt window, and run your java code.
Windows XP
Select Start select Control Panel. double click System and select the Advanced tab.
Click Environment Variables. In the section System Variables find the PATH environment variable and select it. Click Edit. If the PATH environment variable does not exist, click New.
In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. Click OK. Close all remaining windows by clicking OK.
Reopen Command prompt window, and run your java code.
Setting Permanent Path In Mac OS
Mac OS မှာ JDK ကို install လုပ်ထားတဲ့ path သို့မဟုတ်location နဲ့ version အလိုက် Path ကို အောက်ဖော်ပြပါ ဉပမာအတိုင်း Terminal မှာ ပေးနိုင်တယ်။
export JAVA_HOME= /Library/Java/Home
Setting Permanent Path In Linux
Linux မှာ JDK ကို install လုပ်ထားတဲ့ path သို့မဟုတ် location နဲ့ version အလိုက် Path ကို အောက်ဖော်ပြပါ ဉပမာအတိုင်း Terminal မှာ ပေးနိုင်တယ်။
export PATH=$PATH: /home/jdk1.8.0_121/bin/
Testing The Configuration
Path ပေးပြီးသွားရင် Windows Command Prompt သို့မဟုတ် Terminal မှာ javac -version သို့မဟုတ် java -version လို့ ရိုက်ရင် install လုပ်ထားတဲ့ version ကို ပြသပေးပါလိမ့်မယ်။
အဲ့ဒါဆိုရင် သင့်ရဲ့ ပထမဉီးဆုံး Java ပရိုဂရမ်ကို စတင် Create, Compile, Execute လုပ်လို့ ရပါပြီ။
Comments
Post a Comment