Java vs C # compiled source files

Source: Internet
Author: User

We know that Java, like C #, is run on a virtual machine-based environment. Virtual machines in Java are called JVMs (Java Virtual machine), while C # is called the CLR (Common Language Runtime). With virtual machines, these two programming languages enable the so-called cross-platform functionality.

Let's do a simple experiment to review how Java and C # compile the source files.

One, the Java compilation source file

The premise of compiling is to install the JDK (Java development Kit), if the installation of the JRE (Java Runtime Environment) can not be compiled, only run.

After the installation, for ease of operation, we need to add the D:\Program files\java\jdk1.7.0_25\bin (see your install directory) directory to the environment variable, and then you can directly use the CMD command Window Javac, Java and other commands.

Take HelloWorld as an example:

Create a Java source file named Test.java on the D drive, and then edit the content as:

public class test{public    static void Main (String [] args) {System.out.println ("Hello World");}    }

As shown above, the Execute Javac command generates a Test.class file under the D disk, and the Java Test command runs the generated test.class file.

This completes the compilation of the Java source files.

Ii. C # compiling source files

Similar to Java, C # performs file compilation operations that require the CSC command, provided that the. NET Framework is installed.

Also, to facilitate the use of the CSC command directly in the CMD command window, we add the directory to the environment variable of the Windows system.

The directory where I have the. NET Framework for this machine is: C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319, or you can select a different version of the. NET Framework.

Or take HelloWorld as an example:

We build a C # source file named TestCSharp.cs in D, and then edit the content as:

Using System;namespace test{public class testcsharp{public static void Main (string [] args) {Console.WriteLine ("Hello World. ");}}}

Executing the CSC TestCSharp.cs command generates a TestCSharp.exe executable file in the current directory and then directly enters the file name to run. As to why the CSC can be understood this way, CSC (C sharp compile,c# compiles).

For more options on the C # csc command, refer to: http://msdn.microsoft.com/zh-cn/library/78f4aasd.aspx


PostScript: Java, like C #, is an object-oriented, compiled programming language. They are all based on virtual machine programming languages and can theoretically be implemented across platforms. By compiling, Java generates a class bytecode file, and C # generates the corresponding IL intermediate language, which is the same design idea.


Java vs C # compiled source files

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.