java and c# [this is a bonus – it is not a required lesson] aco101: introduction to computer...
TRANSCRIPT
![Page 1: Java and C# [this is a bonus – it is not a required lesson] ACO101: Introduction to Computer Science](https://reader035.vdocument.in/reader035/viewer/2022070410/56649ec65503460f94bd1385/html5/thumbnails/1.jpg)
Java and C#[this is a bonus – it is not a required lesson]
ACO101: Introduction to Computer Science
![Page 2: Java and C# [this is a bonus – it is not a required lesson] ACO101: Introduction to Computer Science](https://reader035.vdocument.in/reader035/viewer/2022070410/56649ec65503460f94bd1385/html5/thumbnails/2.jpg)
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.
![Page 3: Java and C# [this is a bonus – it is not a required lesson] ACO101: Introduction to Computer Science](https://reader035.vdocument.in/reader035/viewer/2022070410/56649ec65503460f94bd1385/html5/thumbnails/3.jpg)
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
![Page 4: Java and C# [this is a bonus – it is not a required lesson] ACO101: Introduction to Computer Science](https://reader035.vdocument.in/reader035/viewer/2022070410/56649ec65503460f94bd1385/html5/thumbnails/4.jpg)
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)
![Page 5: Java and C# [this is a bonus – it is not a required lesson] ACO101: Introduction to Computer Science](https://reader035.vdocument.in/reader035/viewer/2022070410/56649ec65503460f94bd1385/html5/thumbnails/5.jpg)
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
![Page 6: Java and C# [this is a bonus – it is not a required lesson] ACO101: Introduction to Computer Science](https://reader035.vdocument.in/reader035/viewer/2022070410/56649ec65503460f94bd1385/html5/thumbnails/6.jpg)
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.
![Page 7: Java and C# [this is a bonus – it is not a required lesson] ACO101: Introduction to Computer Science](https://reader035.vdocument.in/reader035/viewer/2022070410/56649ec65503460f94bd1385/html5/thumbnails/7.jpg)
To DIY you will need
The Java SE Development Kit 6 (JDK 6)
• http://www.oracle.com/technetwork/java/javase/downloads/index.html
• Download and follow the installation wizard
.NET Framework Software Development Kit (SDK)
• http://www.microsoft.com/downloads/details.aspx?FamilyID=fe6f2099-b7b4-4f47-a244-c96d69c35dec&displaylang=en
• Download and follow the installation wizard
• Or install Visual Studio 2008 and/or Visual Studio 2010
![Page 8: Java and C# [this is a bonus – it is not a required lesson] ACO101: Introduction to Computer Science](https://reader035.vdocument.in/reader035/viewer/2022070410/56649ec65503460f94bd1385/html5/thumbnails/8.jpg)
Hello world
Javapackage 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(); }
}}
![Page 9: Java and C# [this is a bonus – it is not a required lesson] ACO101: Introduction to Computer Science](https://reader035.vdocument.in/reader035/viewer/2022070410/56649ec65503460f94bd1385/html5/thumbnails/9.jpg)
Save as….
Java• myfirstjavaprog.java
C#• myfirstcharpprog.cs
![Page 10: Java and C# [this is a bonus – it is not a required lesson] ACO101: Introduction to Computer Science](https://reader035.vdocument.in/reader035/viewer/2022070410/56649ec65503460f94bd1385/html5/thumbnails/10.jpg)
Bring up a command prompt
For java - Start > Run > cmd For c#
![Page 11: Java and C# [this is a bonus – it is not a required lesson] ACO101: Introduction to Computer Science](https://reader035.vdocument.in/reader035/viewer/2022070410/56649ec65503460f94bd1385/html5/thumbnails/11.jpg)
Change the directory to the location of
Java – the compilerC:\Program Files\Java\jdk1.6.0_21\bin C# -- the file to be compiled
(it will different on your computer than on mine)
![Page 12: Java and C# [this is a bonus – it is not a required lesson] ACO101: Introduction to Computer Science](https://reader035.vdocument.in/reader035/viewer/2022070410/56649ec65503460f94bd1385/html5/thumbnails/12.jpg)
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]
![Page 13: Java and C# [this is a bonus – it is not a required lesson] ACO101: Introduction to Computer Science](https://reader035.vdocument.in/reader035/viewer/2022070410/56649ec65503460f94bd1385/html5/thumbnails/13.jpg)
Now go check to see if you have a
java C#• .exe file• .class file
![Page 14: Java and C# [this is a bonus – it is not a required lesson] ACO101: Introduction to Computer Science](https://reader035.vdocument.in/reader035/viewer/2022070410/56649ec65503460f94bd1385/html5/thumbnails/14.jpg)
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
![Page 15: Java and C# [this is a bonus – it is not a required lesson] ACO101: Introduction to Computer Science](https://reader035.vdocument.in/reader035/viewer/2022070410/56649ec65503460f94bd1385/html5/thumbnails/15.jpg)
Success!
Java C#
![Page 16: Java and C# [this is a bonus – it is not a required lesson] ACO101: Introduction to Computer Science](https://reader035.vdocument.in/reader035/viewer/2022070410/56649ec65503460f94bd1385/html5/thumbnails/16.jpg)
Hungry for more?
Java• http://
download.oracle.com/javase/tutorial/java/package/packages.html
• http://en.wikipedia.org/wiki/Java_package
C#• http://
msdn.microsoft.com/en-us/library/ms379563%28VS.80%29.aspx#csharpcompiler_topic4
• http://www.csharphelp.com/2006/02/namespaces-in-c/