Powered by Blogger.

Mencoba Notepad++ NppExec Add Java Compiler

Notepad++ NppExec Add Java Compiler

ceritanya nih.. ternyata notepad bisa kita jadikan seperti hampir memiripkan daripada IDE java, macam Jcreator... intinya setelah kita tulis kodenya, kemudian kita save sebagai file .java dan kita bisa mengkompilasinya sehingga menjadi file .class yang bisa kita eksekusi langsung dari notepad++.
 Awal mulanya mencari hal seperti.. secara nggak sengaja Jcreator yang ku install minta code untuk unlock, seetelah  google akhirnya ketemu halaman blog berikut : http://setup-steps.blogspot.com/2013/05/notepad-nppexec-add-java-compiler.html dan step-stepnya adalah seperti berikut  :

1) If you haven't installed NppExec PlugIn, follow this tutorial, http://setup-steps.blogspot.com/2013/05/notepad-adds-plug-in-nppexec.html, before proceeding to the next step.

2) Configure the NppExec Plugin:

Go to Plugins > NppExec and apply the followings:
1. Disable "Console Command History"
2. Enable "Save all files on execute"
3. Enable "Follow $(CURRENT_DIRECTORY)"


3) Add Compile command:
3.1. Go to Plugins > NppExec > Execute...
3.2. Choose “Cancel” if  a Save File… dialog box appears
3.3. Enter the following command:
cd “$(CURRENT_DIRECTORY)”
javac $(FILE_NAME)



3.4. Click Save. Type the name as "Compile".




4) Add Run command:

cd "$(CURRENT_DIRECTORY)"
java)$(NAME_PART)


5) Add Compile and Run command:

cd "$(CURRENT_DIRECTORY)"
javac $(FILE_NAME)
java $(NAME_PART)




6) Add the Execute Command Names as menu.
6.1) Go to NppExec Advance Options:



6.2)  enable "Place to the Macros submenu".


6.3) Then select “Compile” from under the “Associated script:” menu, and click the
“Add/Modify” button:



6.4) Repeat this process for the other two scripts, be careful to type the names “Run” and
“Compile and Run” in the “Item name:” box before hitting the Add/Modify button.


7) Restart Notepad++.

8) Test by creating Test.Java file.

public class Test {
public static void main(String[] args) {
System.out.println("Hello world!");
}
}

9) Go to menu  Macro/Compile.


9.1) In case you get an error like below:


9.1.1) Change your command as follows:


cd $(CURRENT_DIRECTORY)
C:\Program Files\Java\jdk1.7.0_21\bin\javac $(FILE_NAME)



It could be caused by Windows not knowing the path to javac program (possibly true when you are using Notepad++ Portable Version, because it is running in its own memory container).

10) A successful Compile Command would result as follow:


11) A successful Compile and Run Command would result as follow:



nah.. berikut yang kualami ketika mendapatkan error

Could not find the main class: Test.  Program will exit.
jadi mumet..

setelah bermain-main dengan google ... dan mencoba-coba macam programer amatiran akhirnya ketemu ini, dan "Hello world!" moentjoel.. hahahahaha...


cd "(CURRENT_DIRECTORY)"
C:\Program Files\Java\jdk1.6.0_25\bin\java -cp . $(NAME_PART)
noted : leptop jadulku masih pakai jdk yang belum terupdate
             intinya adalah pada opsi -cp . file.class (perhatikan spasinya!)

begono...
--end--

Reference:
1) http://www.cs.auckland.ac.nz/compsci101s1c/resources/Notepad/Notepad++.pdf
2) http://blog.sanaulla.info/2008/07/25/using-notepad-to-compile-and-run-java-programs/

Bannerad

Artikel Terpopuler

Tags

Blogumulus by Roy Tanck and Amanda Fazani