Java to C# Translator - c#

I heard that JNBridge will translate C# code to native Java code.( I haven't tested it).
Is there any tool available in market to translate Java code to native C# ?(or Will JNBridge also translate Java code to C# ?)

Are you talking about a source code converter, or the ability to run Java code in a CLR?
If it's the latter, you might want to look at IKVM:
IKVM.NET is an implementation of Java
for Mono and the Microsoft .NET
Framework. It includes the following
components:
A Java Virtual Machine implemented in
.NET
A .NET implementation of the Java
class libraries
Tools that enable Java
and .NET interoperability

Microsoft's Visual Studio 2005 included a Java to C# conversion tool (the Java Language Conversion Assistant). Although they announced in 2007 it wouldn't be developed further (and it isn't in VS 2008) it is still a supported product until 2015.

I don't think that direct "code translating" could be possible, what with invoking API functions? (like, each technology has it's own collections, etc.). Link that you have given, doesn't seem to be code translator, rather - libraries that allows one to connect components, like embedding java GUI inside WPF app etc.
Also, on the main page of JNBridge, they are writing:
Bridge anything Java to .NET
Bridge anything .NET to Java
So it might a good idea to check someone's site before asking about possibilities of their platform.

Related

Call C# dll from a Java Application

I have a dll created in c# which does some database operation upon calling. I have to pass few parameters from a Java application to a method in the dll. Any Idea on how to do this.
OR
Any better ideas for calling a method in c# by a java application?
Thanks
Edit : My java application is a standard Dialogue Designer application from AVAYA Platform and I have developed a C# application which works on a SDK for .net only. So i need data to be passed from java application to .net application
IKVM.NET is an implementation of Java for Mono and the Microsoft .NET Framework. It includes the following components:
A Java Virtual Machine implemented in .NET
A .NET implementation of the Java class libraries
Tools that enable Java and .NET interoperability
The third point is maybe what you are looking for.
Project Site here: http://www.ikvm.net/
I looked into this a while back although I enver got far with it as the requirements changed. But I did read that using JNI, Java Native Interface may be able to help you with what you are needing to do.
http://java.sun.com/developer/onlineTraining/Programming/JDCBook/jni.html
Hope this helps!

C# and .NET relation

I know its extensive topic but I have failed to find some basic overview. I would like to know what is exactly the relation between these two. I know I need .NET SP2 to work with VS 2010, so client PC will need to have the same version of .NET I guess.
I would be very grateful if someone could tell me in a few sentences what is .NET and how it relates ti C#
.NET is a framework. What that means is that the .NET platform contains libraries of existing code and architecture from which all applications utilizing it build from. So rather than pouring a new foundation for every house, you already start off with a solid one that has been perfected and improved upon over time. In addition to a starting foundation, the framework serves as a sort of toolbox of existing code that saves you from reinventing the wheel every time you need certain things.
For instance, winforms is an established foundation from which to build windows applications with a rudimentary user interface simply by going to file > new project. You would have to interface with GDI yourself to generate windows forms and user interface if this library of existing code was not there to support you.
C# is simply a programming language. One specifically written with .NET in mind. In fact, most of the .NET framework is written in C# (if not all of it). It's syntax is simply the next progression of the C language, thus transitioning from C++ to C# shouldn't be too difficult. It's a paradigm shift with a lot of things, but at least the syntax is often familiar. Any .NET language is usually compatible with other .NET languages. For instance, I could write a class library in Visual Basic, and you could use that compiled library in your C# program.
Because .NET is a framework, the code you reference in it does not get compiled into your program, rather a reference to code in the framework is all that gets compiled. This means that clients running your program must also have the .NET framework, albeit a stripped down version. They don't need all the development tools that you need so their .NET framework download is a little smaller. Clients running Windows Vista/7 don't need to worry about anything; it's included with their OS. Only certain users running XP would even have to worry about downloading the framework, and most programs accurately detect the requirement and inform the end user to go download it.
All versions of Visual Studio are simply tools to help you build applications and better utilize the .NET framework. I would never recommend coding in any .NET language without at least the express (free) edition of visual studio. Intellisense alone is worth it. That said, it is definitely possible to code something in .NET without the Visual Studio IDE. You could open up notepad right now and write a C# program, compile it with the free compiler, and run it. While Visual Studio 2010 is pretty amazing, and uses the new WPF platform to run, 2008 will serve you just as well. 2010 is optimized for .NET 4 but works just fine when targeting previous versions of .NET as well.
Bottom line:
.NET is a coding framework.
C# is a language built to take advantage of .NET. NOTE: Visual Basic is also a .NET language and choosing between C# and VB is simply a matter of preference.
Visual Studio is a tool to help you in coding for .NET.
That is how they are all related.
(This is probably a duplicate, but the best answer is off-site)
Quoting from Jon Skeet:
Untangling the Versions
There are lots of different versions of different elements of development. You need to distinguish between the versions of Visual Studio (the IDE), C# (the language) and .NET (the framework). It's quite hard to talk about each of these individually without bringing in other pieces, but I'll see what I can do... Note that I'll avoid introducing the CLR versions as well, as most developers don't really need to know about that.
.NET Framework versions
There have been five significant releases of the .NET Framework, excluding service packs. The framework includes the compilers, runtime, and libraries.
1.0 - released in 2002
1.1 - released in 2003
2.0 - released in 2005, with a new CLR (to handle generics and nullable types) and compilers for C# 2 and VB 8.
3.0 - released in 2006, this is just 2.0 plus new libraries: Windows Presentation Foundation, Windows Communication Foundation, Workflow Foundation, and Cardspace
3.5 - released in 2007, this is 3.0 plus new libraries (primarily LINQ and some extra "base" libraries such as TimeZoneInfo) and new compilers (for C# 3 and VB 9)
C# language versions
There are three significant language versions:
C# 1
C# 2, introducing generics, nullable types, anonymous methods, iterator blocks and some other more minor features
C# 3, introducing implicit typing, object and collection initializers, anonymous types, automatic properties, lambda expressions, extension methods, query expressions and some other minor features
Read the rest here: http://csharpindepth.com/Articles/Chapter1/Versions.aspx
Basically:
.NET is a programming environment including, among other things, a virtual machine (the CLR) and an extensive class library (the BCL)
C# is a programming langage that targets the .NET environment. It is compiled to IL (a kind of assembly language executed by the CLR), and uses the classes from the BCL
The information HERE might be helpful to you.
C# is a programming language, very similiar to c++.
.NET is a set of libraries, classes, ready to use methods etc.
It is strictly related to C#. You use them both without noticing it :)
Every 'using' statement imports a set of classes to your project from .NET.
As Chevex says .NET is a framework and C# is just one of several languages targeting the framework.
Not sure about what you mean about "SP2" and VS2010. The language features you use will determine what version of the framework is required on the clients running your code.
See here for more information:
http://msdn.microsoft.com/en-us/library/bb822049.aspx
http://msdn.microsoft.com/en-us/library/8z6watww.aspx

Is Java Virtual Machine provided by Sun written in Java? Is Dot Net Framework in C++ or C#?

I am talking about the major implementation platform of these platforms.
For Java, the JVM itself is written in C++, probably with a little C or even assembler sprinkled in. The Standard API library, on the other hand, is written almost entirely in Java (with a few native methods implemented in C or C++).
The JVM provided by Sun (Hotspot) is written in C++, although parts of the standard Java library is written in Java as well.
The same goes for .NET. The VM and core libraries (interfacing with the underlying platform and native libraries) are written in C++ , the rest is written in C#.
I'm not sure about the dot net framework, but the jvm is build using a combination of c and java, see also the sources for yourself:
http://download.java.net/jdk6/source/
The bulk of the .Net framework is written in C#. Evidence for this would be Microsoft's Rotor project, which is basically the source code for much of the .Net framework. However, the core libraries are written in C++, including the virtual machine itself and the libraries that interface directly with the operating system.
As for Java, it is much the same as .Net in the way it is programmed.

When do I need the Windows SDK and what is .NET for?

I am a student and after taking some introductory programming courses in Java, C, and just finishing up a book on C++, I would like to start developing applications for Windows.
I have done my best to page through google and find the answers I need, but I seem to be at a loss.
When would I need the Windows SDK over just the regular API?
And what is .NET and why would I need it?
What is so special about C# and should I use that over C/C++?
When would I need the Windows SDK over just the regular API?
The SDK includes headers, libraries, tools, etc., that give you access to the API (and to .NET, for that matter). For example, a typical API-based program will start with #include <windows.h> -- but without the SDK, you don't have a copy of Windows.h to include. Likewise, the SDK includes the compilers (the same actual compilers included in the current version of Visual C++), linkers, debuggers, etc., necessary to actually build an API-based program.
And what is .NET and why would I need it?
.NET is a couple of things: a virtual machine that executes code in what Microsoft calls "intermediate language" (IL). It's also a (large) library of code in IL for everything from window management and drawing to communications, system management, etc.
You'd need it primarily if you were writing code in a .NET-based language such as C#, VB.NET, etc.
What is so special about C# and should I use that over C/C++?
C# is (by far) the preferred language for .NET development. Microsoft did develop .NET versions of Visual BASIC, and something at least quite similar to C++, but both tend to lag behind C# (at best).
So, if you're developing code specifically for Windows (especially if it includes a GUI), C# is probably your first choice. Microsoft does a lot more to support it than to support C or C++. That shows up in better support in both libraries and tooling.
The primary argument in favor of using C or C++ would probably be that you're developing primarily for Linux, and then porting the code to Windows. You can still do such development in C# if you want to (e.g., you can run C# and .NET under Linux using Mono), but especially if you're doing the development work under Linux, you lose most of the advantages.
On the other hand, if your code doesn't involve a GUI anyway, you might be able to write portable C or C++, and just compile it under both Windows and Linux. In such a case, using C# could involve extra work, such as having to install Mono to run the code under Linux--not a terribly difficult task, but even a fairly easy installation can be more work than no installation at all.
Windows SDK is a low-level framework for developing applications specifically for Windows. You could use it for your development. However, the APIs are low-level and a little difficult to use and maintain.
Alternatively, you could use .Net. .Net is a framework that includes runtime support for your application. It has many packages, I am sure you will find something useful in .Net. .Net needs a runtime for executation and is not compiled natively to the platform. However, it is easier for software development mostly because the APIs are higher level.
C# is the recommended language for Windows specific programming, specially on .Net. Not that it is the only language, you could also use C/C++, but they are not supported by Microsoft actively. For example, if you use C#, creating a GUI application could just a few mouse clicks. Using C++, you would need to manage your windows instances.
Typically, you would only use C/C++ for Windows programming if you are doing cross-platform programming or some low-level stuffs.

Is it C# or C#.NET?

I always see people writing "C#" and "C#.NET". What is the correct name of this language? C# or C#.net? I'm sorry for this stupid question but it is really confusing (maybe there's another programming language named C#.net?)...
EDIT: if I'm programming against the .NET Framework, why call this C#.NET? Can I use the C# language with other frameworks?
C# is a language, .NET is platform.
There are lot of languages on .NET: C#, Visual Basic, IronRuby and more.
wiki
The other answers are close but not quite right.
C# is the language, it is specified in an ISO standard.
.NET is the platform from Microsoft.
Visual C# .NET was the name of the developer tool in 2002. The name was shortened to "Visual C#" with the 2003 release. The more popular, expansive cousin is "Visual Studio". Subsequent to 2003, Microsoft dropped the independent commercial product called "Visual C#" (along with Visual Basic .NET) and introduced the free Express products. The current version is called Visual C# 2008 Express Edition, some people call it "Visual C# Express" for short.
In the same way, there is C++, and there is "Visual C++". The former is a language, the latter is a tool from Microsoft that you can use to write/compile/test/debug apps in the language, on Windows. (But again, most people use "Visual Studio" , which includes all the capabilities of Visual C# and Visual C++)
Basically,
C# is the language you're programming in.
.NET if the framework you're programming against.
The combination is C#.NET. There's also VB.NET, C++.NET, for when you're programming in VB/C++ against the .NET framework.
The language is C#, and the framework/platform it runs on is .NET. C# is purely a .NET language, there is no variant of it that is targeted on another platform, unlike for instance Visual Basic (this is why VB and VB.NET can mean different things).
But C# is always "C#.NET" and is called just C#.
When people say they are using "C#.Net", they mean they are developing on the .Net platform while using C#
"VB or VB.NET" makes sense as there are both .NET and non-.NET versions of the language. It does not make sense with C# because there is only a .NET version.
Similar with ASP and ASP.NET. The non-.NET version is usually called "Classic ASP."
I've never heard the C# language referred to as "C# .NET" but I guess you could reasonably use that term (even if it's a little redundant.)
So don't worry, there is only one C# language.
The C# language is only used with the .NET Framework. So when people say C#, it always means C# on the .NET Framework. Since C# isn't used with any other frameworks (as of writing this) the .NET in C#.NET is redundant.
Visual Basic on the other hand can either be the old VB Runtime or VB.NET. So VB needs the .NET qualification so you really know what you language you are really talking about because VB 6 and VB.NET are pretty different.
When I hear someone say C#.NET, it is usually from someone who isn't a programmer. Most recruiters see .NET appended to things like VB, Visual Studio and ASP, so they naturally append it to C# because for them, it is easier to just think everything is .NET.
There was a time when the marketing guys at Microsoft were sticking the suffix ".NET" on to every MS product they could. Sometimes it made sense - e.g. to distinguish VB 6.0, and earlier versions, from what came after. Other times it was just marketing phooee; at one point I think they were going to rechristen all the server products with the .NET suffix: Windows.NET Server, SharePoint.NET Services etc.
But it was a short-lived phenomenon and quickly dropped (in some cases before the products were actually launched).
In the case of C#, there was no earlier version and only later the prospect of publishing the spec and seeing other implementations, so it made little difference whether it was called C#.NET or just C#.
I guess that's just marketing guys for you - they did exactly the same with the "Active" prefix before that...
The language is C#. C# is also a popular language on the NET platform, so people often say C#.NET. The same thing used to happen for C++, where people would call it Visual C++. In both cases, what they really mean is C# using .NET and C++ using MFC.
C# is language. But it's always C#.net because C# language added to the Visual Studio Family when the Visual Studio.NET released.
In Visual Studio 6, C# was not there.
In Visual Stuio .NET in 2002/2003, C# was introduced.
".NET" for the general branding for VS 2002. So it was attached to everything related to it also "C#" is always-dotnet by it's nature.

Categories