You don't need Visual Studio to create or compile any .NET language. Simply type code into a regular text editor, save it and type a command in the Windows Command window to compile your application. Many developers, however, use Microsoft Visual Studio to perform this task because VS does it much faster. If you write JScript code, however, you must compile it from the Windows Command window using syntax similar to that shown below:
"MyJScriptFile" is the name of the file you wish to compile.
One of the benefits of compiling a program is being able to discover errors before finding them in your browser after a Web page loads. Compiling a .NET application gathers all its components, checks them for errors and produces an object called an assembly. When the compiler discovers an error while compiling one of your JScript files, the compiler displays the error and terminates the compilation process. You cannot run your application until you resolve the errors.
Common JScript Compilation Errors
Because you cannot use Visual Studio's convenient error window to identify errors, you must work with the messages that appear in the Windows Command window when compiling. After you type "jsc MyJScriptFile.js" in the Command window, the compiler might respond with the following error message:
fatal error JS2035: Could not find file 'MyJScriptFile.js"
This occurs when the compiler cannot find a file named "MyJScriptFile.js." If your code contains a statement such as the one shown below, you will also see a compilation error, such as "JS1135":
varr y = 2;
That error occurs because varr is not a valid keyword. Pay attention to text that appears next to any compiler error; it may help you discover how to resolve the problem get the application working.
- Photo Credit Brand X Pictures/Brand X Pictures/Getty Images