Microsoft J Script Compilation Errors

  • Print this article
Microsoft J Script Compilation Errors thumbnail
Compiler errors may be frustrating, but you can often resolve them.

Microsoft .NET developers familiar with languages such as C# and VB.NET may be surprised to learn about JScript 10.0, a new scripting language similar to the old Microsoft JScript language. Both languages are similar to JavaScript, but JScript 10.0 is more powerful and allows you to compile JScript applications as you do with other .NET languages such as C# and VB.NET. While compiling a JScript 10.0 application, you may encounter compilation errors that you must resolve.

  1. JScript VS JavaScript

    • Anyone can use JavaScript to build a Web page by typing JavaScript statements into an HTML file. When you click a button or press a key on a page running JavaScript, the code runs inside the browser without contacting a Web server. JScript however, functions like other .NET languages such as C# and VB.NET; JScript runs on the Web server that delivered the Web page. JScript 10.0 also allows you to manipulate the .NET framework, work with classes and create object-oriented applications.

    Compilation

    • 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:

      jsc myJScriptFile.js

      "MyJScriptFile" is the name of the file you wish to compile.

    Compilation Errors

    • 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.

Related Searches

References

Resources

  • Photo Credit Brand X Pictures/Brand X Pictures/Getty Images

Comments

Related Ads

Featured
View Mobile Site