Java vs C# Johan Lindfors Microsoft AB. What are we to cover?  Java vs C#  Similarities and differencies  Specific issues  Deployment of applications.

Slides:



Advertisements
Similar presentations
Using.NET Platform Note: Most of the material of these slides have been taken & extended from Nakov’s excellent overview for.NET framework, MSDN and wikipedia.
Advertisements

What is RMI? Remote Method Invocation –A true distributed computing application interface for Java, written to provide easy access to objects existing.
 Specifies a set of methods (i.e., method headings) that any class that implements that interface must have.  An interface is a type (but is not a class).
15-May-15 RMI Remote Method Invocation. 2 “The network is the computer” Consider the following program organization: If the network is the computer, we.
C# and Windows Programming Application Domains and Remoting.
.NET REMOTING CertSIG Tom Perkins. FUNDAMENTALS Distributed Applications Process A Process B Process C Objects can communicate across process boundaries.
.NET Remoting. .Net Remoting Replaces DCOM (Distributed Component Object Model – a proprietary Microsoft technology for communication among software components.
Java Remote Method Invocation (RMI) In Java we implement object systems: O1O2 O3 thread 1thread 2 execution scheme JVM 1JVM 2 distribution scheme.
The road to reliable, autonomous distributed systems
Remote Method Invocation Chin-Chih Chang. Java Remote Object Invocation In Java, the object is serialized before being passed as a parameter to an RMI.
DISTRIBUTED FILE SYSTEM USING RMI
Event Handling Events and Listeners Timers and Animation.
EEC-681/781 Distributed Computing Systems Lecture 5 Wenbing Zhao Department of Electrical and Computer Engineering Cleveland State University
Distributed Systems Tutorial 2 -.NET Remoting. 2 What is Remoting?  Remoting allows you to pass objects or values across servers in different domains.
1 Web Services Visual C# 2008 Step by Step Chapter 30.
Applets  The Applet Class  The HTML Tag F Passing Parameters to Applets.
Beyond DHTML So far we have seen and used: CGI programs (using Perl ) and SSI on server side Java Script, VB Script, CSS and DOM on client side. For some.
Meir Botner David Ben-David. Project Goal Build a messenger that allows a customer to communicate with a service provider for a fee.
.NET Remoting Architecture. Slide 2 CITE 4420.NET Remoting Topics Remoting Boundaries Crossing the Boundaries Distributed Applications Marshalling Channels.
ASP.NET  ASP.NET is a web development platform, which provides a programming model, a comprehensive software infrastructure and various services required.
Java RMI Essentials Based on Mastering RMI Rickard Oberg.
1 Java Programming II Java Network II (Distributed Objects in Java)
Assemblies & Namespaces1. 2 Assemblies (1).NET applications are represented by an assembly An assembly is a collection of all software of which the application.
EJB Framework.  As we know, EJB is the center of the J2EE architecture that provides a sturdy framework for building enterprise applications. The major.
Distributed Communication via ASP.Net Web Services and.Net Remoting By Richard King.
第十四章 J2EE 入门 Introduction What is J2EE ?
J2EE Structure & Definitions Catie Welsh CSE 432
CSCI 6962: Server-side Design and Programming Web Services.
CS795/895: Introduction. Topics Distributed Systems –Availability –Performance –Web Services Security –Authentication –Authorization –Confidentiality.
11 Web Services. 22 Objectives You will be able to Say what a web service is. Write and deploy a simple web service. Test a simple web service. Write.
Component-Based Software Engineering Introduction to.NET Paul Krause.
.NET Framework Danish Sami UG Lead.NetFoundry
LAB 1CSIS04021 Briefing on Assignment One & RMI Programming February 13, 2007.
1 Java RMI G53ACC Chris Greenhalgh. 2 Contents l Java RMI overview l A Java RMI example –Overview –Walk-through l Implementation notes –Argument passing.
Module 3: Working with Components. Overview An Introduction to Key.NET Framework Development Technologies Creating a Simple.NET Framework Component Creating.
Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 RMI.
RMI Continued IS Outline  Review of RMI  Programming example.
RMI remote method invocation. Traditional network programming The client program sends data to the server in some intermediary format and the server has.
RMI Remote Method Invocation Distributed Object-based System and RPC Together 2-Jun-16.
By: PHANIDEEP NARRA. OVERVIEW Definition Motivation.NET and J2EE Architectures Interoperability Problems Interoperability Technologies Conclusion and.
 Remote Method Invocation  A true distributed computing application interface for Java, written to provide easy access to objects existing on remote.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Introduction to Spring Remoting Simplifying.
VITALE, CATURANO & COMPANY LTD Microsoft SharePoint Web Part Development Overview VITALE, CATURANO & COMPANY LTD SharePoint Developer Series – Web Part.
Li Tak Sing COMPS311F. RMI callbacks In previous example, only the client can initiate a communication with the server. The server can only response to.
Chapter 14 Applets and Advanced GUI  The Applet Class  The HTML Tag F Passing Parameters to Applets F Conversions Between Applications and Applets F.
Object Oriented Programming.  Interface  Event Handling.
Bill Campbell, UMB Microsoft's.NET C# and The Common Language Runtime.
1 Java Remote Method Invocation java.rmi.* java.rmi.registry.* java.rmi.server.*
ASP.NET Web Services.  A unit of managed code installed under IIS that can be remotely invoked using HTTP.
PerlNET: The Camel Talks.NET Jan Dubois The Perl Conference 6 San Diego, July 26 th 2002.
Java Programming: Advanced Topics 1 Enterprise JavaBeans Chapter 14.
.NET Mobile Application Development XML Web Services.
What Is an Event? Events – Objects that describe what happened Event sources – The generator of an event Event handlers – A method that receives an event.
Appendix A: Windows Forms. 2 Overview Describe the structure of a Windows Forms application –application entry point –forms –components and controls Introduce.
UMBC Distributed Computing with Objects RMI/Corba CMSC 432 Shon Vick.
User Interface Programming in C#: Basics and Events Chris North CS 3724: HCI.
1 Lecture 15 Remote Method Invocation Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung Institute of Technology.
Windows Communication Foundation and Web Services
Java Remote Method Invocation (RMI)
Presentation 23 .NET Remoting Introduced
Remote Method Invocation
Knowledge Byte In this section, you will learn about:
Introduction to C# AKEEL AHMED.
Introduction to Web Services
Constructors, GUI’s(Using Swing) and ActionListner
J2EE Lecture 13: JMS and WebSocket
Java Remote Method Invocation
Plug-In Architecture Pattern
Presentation transcript:

Java vs C# Johan Lindfors Microsoft AB

What are we to cover?  Java vs C#  Similarities and differencies  Specific issues  Deployment of applications  GUI applications, event handling  Distributed applications, remoting  Java on.NET  Visual J#.NET  Java Language Conversion Assistant

What are we to cover?  Java vs C#  Similarities and differencies  Specific issues  Deployment of applications  GUI applications, event handling  Distributed applications, remoting  Java on.NET  Visual J#.NET  Java Language Conversion Assistant

Code architecture Java source code C# source code Java byte code CIL.class file.module file.jar file.dll file Compiles toLives inGrouped into

Similarities  Hello world in 4 languages… import java.lang.System; public class HelloWorld { public static void main(String[] args) { System.out.println("Zdravo, zemjata!"); } using System; public class HelloWorld { public static void Main(string[] args) { Console.WriteLine("Salut, monde!"); } Java C#

Keyword similarities  Complex type keywords  class / interface  new  Conditional and flow keywords  if / then / else  switch / case / default  for / while / do while  break / continue  return  Exception handling keywords  try / catch / finally / throw

Keyword differences  Package and namespace keywords  import in Java=using in C#  package = namespace  Complex keywords  extends=: (colon)  implements= :  instanceof= is  super=base  final=sealed / readonly  native=extern  synchronized=lock

Example of issues  Enums  No value types in Java  In C# we support both value and reference types  The compiler handles the strain  Iterations  Iterations are very similar in Java and in C#, but…  ”foreach” is a very powerful ally  Resources  Resource management is also similar, but…  ”using” is your true friend

Other topics  Unmanaged code through ”unsafe”  Attributes  Use keywords as identifiers prefix can be used to differentiate keywords from identifiers using System; public { { } public static void Main() { Console.WriteLine(new test!”)); }

What are we to cover?  Java vs C#  Similarities and differencies  Specific issues  Deployment of applications  GUI applications, event handling  Distributed applications, remoting  Java on.NET  Visual J#.NET  Java Language Conversion Assistant

Imports System.Windows.Forms Public Class Door... Sub lock() MessageBox.Show(...); End Sub... Sub unlock() MessageBox.Show(...); End Sub End Class App Imports System.Windows.Forms Public Class Door... Sub lock() MessageBox.Show(...); End Sub... Sub unlock() MessageBox.Show(...); End Sub End Class.DLL 0101.DLL 0110 Imports System.Windows.Forms Public Class Door... Sub lock() MessageBox.Show(...) End Sub... Sub unlock() MessageBox.Show(...) End Sub End Class Imports System.Windows.Forms Public Class Door... Sub lock() MessageBox.Show(...) End Sub... Sub unlock() MessageBox.Show(...) End Sub End Class Application Deployment on Windows

App Imports System.Windows.Forms Public Class Door... Sub lock() MessageBox.Show(...); End Sub... Sub unlock() MessageBox.Show(...); End Sub End Class.DLL 0101.DLL 0110 Imports System.Windows.Forms Public Class Door... Sub lock() MessageBox.Show(...); End Sub... Sub unlock() MessageBox.Show(...); End Sub End Class Imports System.Windows.Forms Public Class Door... Sub lock() MessageBox.Show(...) End Sub... Sub unlock() MessageBox.Show(...) End Sub End Class Imports System.Windows.Forms Public Class Door... Sub lock() MessageBox.Show(...) End Sub... Sub unlock() MessageBox.Show(...) End Sub End Class Application backout on Windows

App.jar JBC.jar JBC Imports System.Windows.Forms Public Class Door... Sub lock() MessageBox.Show(...); End Sub... Sub unlock() MessageBox.Show(...); End Sub End Class Imports System.Windows.Forms Public Class Door... Sub lock() MessageBox.Show(...); End Sub... Sub unlock() MessageBox.Show(...); End Sub End Class Imports System.Windows.Forms Public Class Door... Sub lock() MessageBox.Show(...); End Sub... Sub unlock() MessageBox.Show(...); End Sub End Class Imports System.Windows.Forms Public Class Door... Sub lock() MessageBox.Show(...); End Sub... Sub unlock() MessageBox.Show(...); End Sub End Class Application Deployment with Java

App.jar JBC.jar JBC Imports System.Windows.Forms Public Class Door... Sub lock() MessageBox.Show(...); End Sub... Sub unlock() MessageBox.Show(...); End Sub End Class Imports System.Windows.Forms Public Class Door... Sub lock() MessageBox.Show(...); End Sub... Sub unlock() MessageBox.Show(...); End Sub End Class Imports System.Windows.Forms Public Class Door... Sub lock() MessageBox.Show(...); End Sub... Sub unlock() MessageBox.Show(...); End Sub End Class Imports System.Windows.Forms Public Class Door... Sub lock() MessageBox.Show(...); End Sub... Sub unlock() MessageBox.Show(...); End Sub End Class Application backout with Java

App Imports System.Windows.Forms Public Class Door... Sub lock() MessageBox.Show(...); End Sub... Sub unlock() MessageBox.Show(...); End Sub End Class Imports System.Windows.Forms Public Class Door... Sub lock() MessageBox.Show(...); End Sub... Sub unlock() MessageBox.Show(...); End Sub End Class Imports System.Windows.Forms Public Class Door... Sub lock() MessageBox.Show(...); End Sub... Sub unlock() MessageBox.Show(...); End Sub End Class Imports System.Windows.Forms Public Class Door... Sub lock() MessageBox.Show(...); End Sub... Sub unlock() MessageBox.Show(...); End Sub End Class.module CIL module CIL NET Upgrade

Imports System.Windows.Forms Public Class Door Sub lock() Sub lock() MessageBox.Show(...); MessageBox.Show(...); End Sub End Sub Sub unlock() Sub unlock() MessageBox.Show(...); MessageBox.Show(...); End Sub End Sub End Class App Imports System.Windows.Forms Public Class Door Sub lock() Sub lock() MessageBox.Show(...); MessageBox.Show(...); End Sub End Sub Sub unlock() Sub unlock() MessageBox.Show(...); MessageBox.Show(...); End Sub End Sub End Class.module CIL Imports System.Windows.Forms Public Class Door... Sub lock() MessageBox.Show(...); End Sub... Sub unlock() MessageBox.Show(...); End Sub End Class Imports System.Windows.Forms Public Class Door... Sub lock() MessageBox.Show(...); End Sub... Sub unlock() MessageBox.Show(...); End Sub End Class.module CIL NET Upgrade backout...

App App GAC Global Assembly Cache

public interface java.awt.event.MouseListener { public void mouseClicked (MouseEvent e); public void mousePressed (MouseEvent e); public void mouseReleased (MouseEvent e); public void mouseEntered (MouseEvent e); public void mouseExited (MouseEvent e); }  Java events are represented by method names grouped into listener interfaces Java Events

class JButton {... public void addMouseListener(MouseListener added); public void removeMouseListener(MouseListener removed);... } Java Event Sources  Java event sources call event methods on registered listeners

class MouseAdapter implements MouseListener { public void mouseClicked (MouseEvent e) {} public void mousePressed (MouseEvent e) {} public void mouseReleased (MouseEvent e) {} public void mouseEntered (MouseEvent e) {} public void mouseExited (MouseEvent e) {} } Java Adapters  Adapter classes allow you to ignore events you're not interested in

class Example {... class OnMousePressedHandler extends MouseAdapter { public void mousePressed(MouseEvent e) {... }... } Java Event Handlers  Declare a handler class that extends the adapter and override the event methods of interest

class Example {... public void init() {... ok.addMouseListener(new OnMousePressedHandler()); } private class OnMousePressedHandler... {... } private JButton ok; }  Create an instance of the handler class and add it to the event source Java Event Example

class Button {... public event EventHandler Click; public event MouseEventHandler MouseDown; public event MouseEventHandler MouseUp; public event EventHandler Enter; public event EventHandler Leave;... }  Event source names their events directly  Every event has a type.NET Events

delegate void EventHandler( object sender, EventArgs sent ); delegate void MouseEventHandler( object sender, MouseEventArgs sent );.NET Event Types  An event type is a method signature  The delegate keyword declares a type

class Example { void OnMouseDown( object sender, MouseEventArgs sent) {... } delegate void MouseEventHandler( object sender, MouseEventArgs sent );  Declare an event handling method matching the event delegate signature.NET Event Handlers

class Example { public Example() {... ok.MouseDown += new MouseEventHandler(OnMouseDown); } private void OnMouseDown(object sender, MouseEventArgs sent){... } private Button ok; }.NET Event Example  Create an event delegate instance using the name of the handler method and add it to the event source

 Make calls between JVMs  Remote object implements a defined remote interface type used by the client  Pass primitive types and objects  Pass-by-value using Java serialization  Pass-by-reference for remote object references  Different transports available  Proprietary, TCP-based protocol (JRMP)  CORBA-compliant IIOP under J2EE  Firewall tunnelling options Distributed Applications RMI/IIOP

 Remote objects registered in registry or JNDI  Client looks up remote object and uses it  Download stub class if required  Two lifecycle options  Server instantiates remote objects and registers them (server is no longer required)  Objects are activated when methods are invoked  RMI also used to communicate with EJBs RMI Lifecycle

 Make calls between application domains  Remoting server links clients to objects  Creates a channel for a given port/protocol  Use TCP or HTTP transports  Pass objects by reference or by value  Remote objects must extend MarshalByRefObject  Objects by value must be Serializable  Need to handle network-related exceptions.NET Remoting

 Use application config file to change settings File-based configuration

Remoting Server Request Create Use Dispose Remote Object Remoting Client Client activation

Remoting Server Request Create Use Dispose Remote Object Remoting Client Server activation – Single Call

Remoting Server Request Create Use Dispose Remote Object Remoting Client Server activation – Singleton Remoting Client Request Use

Advanced.NET Remoting  Client-activated object lifetime  Specified lifetime based on a lease  Server-activated object lifetime  Single call lasts for method duration  Singleton has a specified lifetime based on a lease  Asynchronous calls  Create delegates in the usual way  Pass them to use as callbacks  Wrap remote delegate in AsyncDelegate  Register to be notified of method completion

What are we to cover?  Java vs C#  Similarities and differencies  Specific issues  Deployment of applications  GUI applications, event handling  Distributed applications, remoting  Java on.NET  Visual J#.NET  Java Language Conversion Assistant

Visual J#.NET  The Java language in Visual Studio.NET  Easy transition for Java developer into.NET  Primarily developed to migrate Visual J++ application to.NET  Enables full use of… .NET Framework  XML Web Services in ASP.NET  ADO.NET  Windows Forms  Full cross language integration

What is the JLCA?  Java Language Conversion Assistant  Visual Studio.NET addon  Java language and classes converted to C# and.NET classes  Migrated application will only run on.NET Framework  Numbers right now…  99% of language converted  87% of classes  JBIMP.EXE converts Java bytecode into MSIL

What have we covered?  Java vs C#  Similarities and differencies  Specific issues  Deployment of applications  GUI applications, event handling  Distributed applications, remoting  Java on.NET  Visual J#.NET  Java Language Conversion Assistant

What have we missed?  A bunch of things…  EJB and Serviced Components  Threading and synchronization  Networking  XML processing  Security and Cryptography  Reflection  Database connectivity  Graphics  …

More information  Microsoft and other     MS Press  C# for Java developers  ISBN: .NET Remoting  ISBN:

Definitions  GUIGraphical User Interface  CILCommon Intermediate Language  DLLDynamic Link Library  GACGlobal Assembly Cache  JLCAJava Language Conversion Assistant  JARJava ARchive  JBCJava Byte Code  JRMPJava Remote Method Protocol  JNDIJava Naming and Directory Interface  ISBNInternational Standard Book Number