Compile and Execute Java, C#, and PHP From Your Favorite Text Editors – dzone.com

Join the DZone community and get the full member experience.
Note: The instructions below are based on Windows environment, but are adaptable for Mac/Linux environments.
Assuming JDK to be installed, otherise you need to download that first. You can download it from this link: JDK8
Add the directory that contains your "javac" executable to "PATH" environment variable:
Open "Command Prompt" with administrator rights i.e "Run as administrator".
Execute the following command: SETX /M PATH "%PATH%;C:Program FilesJavajdk1.8.0_20bin"
My javac executable was located in: C:Program FilesJavajdk1.8.0_20
Note: The SETX command will truncate the path to 1024 characters, so it could be destructive.
Press Win+Pause key.
Follow as directed in the screenshot below:

Customize Sublime’s build configuration for Java:
Click on Preferences->Browse Packages
Navigate to Java Folder->JavaC.sublime-build
Modify the contents of this file as:
Change To:
I have modified the value for "cmd" key and changed it to first compile and build the Java program with the "javac" executable, then to run it with "Java" executable.
Restart Sublime Text.
Create or open a Java file and press Ctrl+B to build and execute the Java program. See the example below:

Assuming PHP is installed, otherwise you need to download that first. You can download it from http://windows.php.net/download/ or http://php.net/downloads.php. PHP is already installed with WAMP, XAMPP, and other stacks.
Add the directory that contains your "php" executable to "PATH" environment variable, then follow the same steps as demonstrated above. My "php" executable was located in: C:Serversxamppphp
Create a new build system for PHP. Follow as directed in the screenshot below:

Clicking "New Build System…" will open a new file named "untitled.sublime-build". Replace the contents of this file with:
Press Ctrl+S to save this file, then rename "untitled.sublime-build" to "PHP.sublime-build"

Restart Sublime Text.
Create or open a PHP file and press Ctrl+B to build and execute the PHP script. See the example below:

Assuming.NET framework is present, otherwise you need to download that first. You can download it from https://www.microsoft.com/en-in/download/details.aspx?id=30653.
Add the directory that contains your "csc" executable to the "PATH" environment variable.
Follow the same steps as demonstrated above.
My "csc" executable was located in: C:WindowsMicrosoft.NETFramework64v4.0.30319
Create a new build system for C#. Click on Tools->Build System->New Build System… in Sublime Text.
Clicking "New Build System…" will open a new file named "untitled.sublime-build". Replace the contents of this file with:
Press Ctrl+S to save this file, then rename "untitled.sublime-build" to "CSharp.sublime-build"

Restart Sublime Text.
Create or open a C# file and press Ctrl+B to build and execute the C# program. See the example below:

Install the NPPExec plugin. Follow as directed in the screenshots below:


Configure NPPExec plugin to not display internal messages.

Once the NPPExec plugin is installed and configured, we can move on to create an "Execute" script for compiling and executing Java.
Add the directory that contains your "javac" executable to "PATH" environment variable.
Follow the steps as demonstrated at the start of this article to configure the PATH.
Create an "Execute" script to compile and run Java.

Write the following commands in the "Command(s)" section and type in "JavaExecute" (can be any name here) in the "Script Name" section:
For more information on Notepad++ environment variable, refer to this link: http://docs.notepad-plus-plus.org/index.php/External_Programs

Configure the "JavaExecute" script created above, to be listed as a macro. Follow as directed in the screenshots below:


Restart Notepad++.
Once the "JavaExecute" script is listed as a macro, we need to map a keyboard shortcut to execute this macro so that we can compile and execute Java directly. Follow as directed in the screenshots below:


Once the shortcut has been assigned, create or open a Java file and press Ctrl+Shift+B to build and execute the Java program. See the example below:

Once the NPPExec plugin is installed and configured, we can move on to create "Execute" script for compiling and executing Java.
Add the directory that contains your "php" executable to "PATH" environment variable.
Follow the steps as demonstrated at the start of this article to configure the PATH.
Create an "Execute" script to run PHP. Click on Plugins->NppExec->Execute.. (Refer to screenshot in Step#2 in Compile and execute Java from Notepad++ section)
Write the following commands in the "Command(s)" section and type in "PHPExecute" (can be any name here) in the "Script Name" section:

Configure the "PHPExecute" script created above, to be listed as a macro. Follow as directed in the screenshots below. For bringing up the NppExec Advanced Options dialog, click on Plugins->NPPExec->Advanced Options… (Refer to screenshot in Step#4 in Compile and execute Java from Notepad++ section)

Restart Notepad++.
Once the "PHPExecute" script is listed as a macro, we need to map a keyboard shortcut to execute this macro so that we can execute PHP directly. Follow as directed in the screenshots. For bringing up the Shortcut Mapper dialog, click on Settings->Shortcut Mapper… (Refer to the screenshot in Step 6 in the "Compile and Execute Java From Notepad++" section):

Once the shortcut has been assigned, create or open a PHP file and press Ctrl+Shift+C to execute the PHP program. See the example below:

Once the NPPExec plugin is installed and configured, we can move on to create an "Execute" script for compiling and executing Java.
Add the directory that contains your "csc" executable to "PATH" environment variable.
Follow the steps as demonstrated at the start of this article to configure the PATH.
Create an "Execute" script to compile and execute C#. Click on Plugins->NppExec->Execute.. (Refer to screenshot in Step#2 in Compile and execute Java from Notepad++ section)
Write the following commands in the "Command(s)" section and type in "CSharpExecute" (can be any name here) in the "Script Name" section:

Configure the "CSharpExecute" script created above, to be listed as a macro. Follow as directed in the screenshots below. For bringing up the NppExec Advanced Options dialog, click on Plugins->NPPExec->Advanced Options… (Refer to screenshot in Step#4 in the "Compile and Execute Java From Notepad++" section)

Restart Notepad++.
Once the "CSharpExecute" script is listed as a macro, we need to map a keyboard shortcut to execute this macro so that we can compile and execute C# directly. Follow as directed in the screenshots. For bringing up the Shortcut Mapper dialog, click on the Settings-Shortcut Mapper… (Refer to screenshot in Step#6 in the "Compile and Execute Java From Notepad++" section):

Once the shortcut has been assigned, create or open a C# file and press Ctrl+Shift+N to compile and execute the C# program. See the example below:

Published at DZone with permission of Robin Rizvi. See the original article here.
Opinions expressed by DZone contributors are their own.
ABOUT US
ADVERTISE
CONTRIBUTE ON DZONE
LEGAL
CONTACT US
Let’s be friends:
DZone.com is powered by 

source

Leave a Comment