![]() ![]() ![]() ![]() ![]() This file takes in an argument that it refers as nx1 (1: first arg). For basic compiling and running java code, we can create a batch file say runJavaST2.bat (Windows/ MS-DOS) as OFF We can write our own batch file and call that instead of javac, and in this batch file we can specify any customized build config we want to build and run our project with. Write your own batch file to build all source files in the current directory: If the JDK/bin location is included in System PATH, then javac will compile that file.Ģ. the java compiler is called on the current file name (M圜lass.java). Therefore when we set Tools -> Build System to JavaC and run Tools -> Build/ Ctrl B from a source (say M圜lass.java), the command invoked is javac, i.e. The java build config file has by default 3 key-value pairs as shown below: So for example, the java build config file is in C:\Users\user\AppData\Roaming\Sublime Text 2\Packages\Java\JavaC.sublime-build. Any build config file can be found in the respective language folder here. These configuration files use JSON like key-value pairs and are found in Preferences -> Browse Packages folder (in Windows 7 it is at C:\Users\user\AppData\Roaming\Sublime Text 2\Packages). Sublime Text 2 comes with build config included for most popular languages like C / Java, as long as the compiler locations are included in System PATH. So if we use 64 bit JDK to compile the code and we have a lower version 32 bit JRE also installed, then the compiled class will be run on this older JRE and we’ll get Better is to disable older JREs if not required. If both 64 bit and 32 bit JREs co-exist in a system, then by default it selects 32 bit JRE to run the application. To know your JRE version and whether 32/ 64 bit, open a cmd prompt and type java -version. Ensure that the JRE and JDK versions match, else the compiled classes would not run. Here is what we need to do to get started quickly:ĭefault location of JDK in Windows 7 is C:\Program Files (x86)\Java\jdk1.7.0_13\bin.Īdd this location (or whatever it is in your case) at the end of current System PATH (if other JDKs are installed, put the one to be used before others in the PATH).įor 64 bit JDK, we need to put the corresponding JDK/bin instead (default: C:\Program Files\Java\jdk1.7.0_13\bin). Who wants to launch Eclipse to create a Hello World program (or say a programming assignment at an online course)? Sublime Text 2 is the answer. Follow as directed in the screenshot below:Ĭlicking " New Build System." will open a new file named " untitled.sublime-build".Sublime Text 2 is the latest craze in text editors, and it can be customized to such extent that it has the potential to perform as a light-weight IDE. Step 1Īdd 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:\Servers\xampp\php Step 2Ĭreate a new build system for PHP. PHP is already installed with WAMP, XAMPP, and other stacks. See the example below:Īssuming PHP is installed, otherwise you need to download that first. Step 3Ĭreate or open a Java file and press Ctrl B to build and execute the Java program. 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. Navigate to Java Folder->JavaC.sublime-build Note: The SETX command will truncate the path to 1024 characters, so it could be destructive.įollow as directed in the screenshot below:Ĭustomize Sublime's build configuration for Java: My javac executable was located in: C:\Program Files\Java\jdk1.8.0_20\ Open "Command Prompt" with administrator rights i.e "Run as administrator".Įxecute the following command: SETX /M PATH "%PATH% C:\Program Files\Java\jdk1.8.0_20\bin" You can download it from this link: JDK8 Step 1Īdd the directory that contains your " javac" executable to " PATH" environment variable: Sublime Text 2 Compile and Execute Java From Sublime Text 2:Īssuming JDK to be installed, otherise you need to download that first. Note: The instructions below are based on Windows environment, but are adaptable for Mac/Linux environments. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |