Presentation is loading. Please wait.

Presentation is loading. Please wait.

Java and C# [this is a bonus – it is not a required lesson] ACO101: Introduction to Computer Science.

Similar presentations


Presentation on theme: "Java and C# [this is a bonus – it is not a required lesson] ACO101: Introduction to Computer Science."— Presentation transcript:

1 Java and C# [this is a bonus – it is not a required lesson] ACO101: Introduction to Computer Science

2 Runtime environments Java Java Runtime Environment – Includes the JVM and Common Code Libraries JVM = Java Virtual Machine The JRE was originally designed to support interpreted execution with final compilation as an option. The Java compiler produces Java bytecode C# Common Language Runtime The CLR is designed to execute fully compiled code. The C# compiler produces Common Intermediate Language instructions.

3 Program execution Java bytecode is loaded by the Java runtime and either interpreted directly or compiled to machine instructions and then executed C# the runtime loads Common Intermediate Language code and compiles to machine instructions on the target architecture

4 Installation Check JDK Go to Start > Run > type “cmd” in the box to launch a command prompt – Type in the window (where the cursor is) java –version.NET Framework Software Development Kit (SDK)

5 Location Java C:\Program Files\Java – In folder named jdk1.6.0_21 click into the bin in that folder – C:\Program Files\Java\jdk1.6.0_21\bin – javac.exe is the compiler C# C:\Windows\Microsoft.NET \Framework You will see several different versions – Inside a version folder you will see a csc.exe – This is the compiler program

6 CSC.EXE The command line C# compiler is a program named CSC.EXE. This program makes use of a dynamic link library named CSCOMP.DLL that contains the actual compiler code.

7 To DIY you will need The Java SE Development Kit 6 (JDK 6) http://www.oracle.com/tec hnetwork/java/javase/down loads/index.html http://www.oracle.com/tec hnetwork/java/javase/down loads/index.html Download and follow the installation wizard.NET Framework Software Development Kit (SDK) http://www.microsoft.com/ downloads/details.aspx?Fa milyID=fe6f2099-b7b4-4f47- a244- c96d69c35dec&displaylang =en http://www.microsoft.com/ downloads/details.aspx?Fa milyID=fe6f2099-b7b4-4f47- a244- c96d69c35dec&displaylang =en Download and follow the installation wizard Or install Visual Studio 2008 and/or Visual Studio 2010

8 Hello world Java package hello; class myfirstjavaprog { public static void main(String args[]) { System.out.println("Hello World!"); } C# namespace Hello { public class HelloWorld { public static void Main(string[] args) { System.Console.WriteLine("Hello, World!"); System.Console.ReadLine(); } } }

9 Save as…. Java myfirstjavaprog.java C# myfirstcharpprog.cs

10 Bring up a command prompt For java - Start > Run > cmdFor c#

11 Change the directory to the location of Java – the compiler C:\Program Files\Java\jdk1.6.0_21\bin C# -- the file to be compiled (it will different on your computer than on mine)

12 Now send the your file to the compiler (these have both been run in the screenshot) javac [location and name of.java file] csc /target:exe [name of file]

13 Now go check to see if you have a javaC#.exe file.class file

14 Let’s run it – Java: go to the location of the class (current working directory) and pass the name of the class to the Java runtime C# Double click on the exe

15 Success! JavaC#

16 Hungry for more? Java http://download.oracle.com /javase/tutorial/java/packag e/packages.html http://download.oracle.com /javase/tutorial/java/packag e/packages.html http://en.wikipedia.org/wiki /Java_package http://en.wikipedia.org/wiki /Java_package C# http://msdn.microsoft.com/ en- us/library/ms379563%28VS. 80%29.aspx#csharpcompile r_topic4 http://msdn.microsoft.com/ en- us/library/ms379563%28VS. 80%29.aspx#csharpcompile r_topic4 http://www.csharphelp.com /2006/02/namespaces-in-c/ http://www.csharphelp.com /2006/02/namespaces-in-c/


Download ppt "Java and C# [this is a bonus – it is not a required lesson] ACO101: Introduction to Computer Science."

Similar presentations


Ads by Google