This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Switching from .NET to JAVA help... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Switching from .NET to JAVA help..." Watch "Switching from .NET to JAVA help..." New topic

Switching from .NET to JAVA help...

B Dent

Joined: Mar 14, 2007
Posts: 2
I am a .Net developer (using C#, ASP.NET, Sql Server) thinking of switching to Java and am wondering what are the Java equivalents to .NET?

I understand that C# is kind of like Java so that should not be a problem, but what about the equivalents to ASP.NET and SQL Server? And what books/learning materials would you recommend for those equivalents?
David McCombs
Ranch Hand

Joined: Oct 17, 2006
Posts: 212
From what I understand C# is a little more then "kind of like Java", so moving over should be fairly painless.

For web development there is Servlets and JSP as a starting point.

Pretty much any database can be used with Java.

"Should array indices start at 0 or 1? My compromise of 0.5 was rejected without, I thought, proper consideration."- Stan Kelly-Bootle
Gavin Tranter
Ranch Hand

Joined: Jan 01, 2007
Posts: 333
Having gone from Java to .net (now no longer do .net ) I found the following:
packages in java are roughtly the same as name spaces in c# where they deffer is that in Java a package enforces a physical layout to your code. In C# for a class to be part of a namespace it most be defiend thus:

In java the {} are not need, it is simple enough to make the first statement of the file indicate the package the class belongs too.

Java can only have one public class for source file, no bad thing in my opionon/experience.

Java is a little easier to read, in C# extends is defined using : in Java you use the "extends" keyword.

JSP is roughtly the same as and JDBC is roughtly the same as ADO.NET.

enums in Java are much better and there is a Set collection within its collection framework

I would suggest checking out the tutorials at the Java site, and as far as reference books go, I always found the Java in a nutshell book to be a very good reference to the standard edition API's.

I personally find Eclipse to be a better IDE then Visual Studio, but having said that I probable used both as if they are old DOS IDE's, that is using hardly any of thier functionality. I found visual studio to be unresponsive.

Hope this helps
[ March 14, 2007: Message edited by: Gavin Tranter ]
Gavin Tranter
Ranch Hand

Joined: Jan 01, 2007
Posts: 333
Oh, And there is no special syntax for defining getters and setters.

i.e you cant do:

Sorry I may have got the exact syntax wrong, its been a few months

You have to define your getters and setters as methods. This is perhaps not as neat as C# but it is more readable, as using the C# method it really looks like you are access a public variable.

Campbell Ritchie

Joined: Oct 13, 2005
Posts: 43377
The syntax for adding actions to GUI components is different in Java. You don't use the += notation, but use Listener objects derived from Listener interfaces. There are also classes called Adapters (with an E!) which implement empty methods for every type of Listener interface which has more than one method. I don't like Adapters myself because a tiny spelling error in a method identifier can cause unexpected failure of the button to work.

In this respect, I dislike what the Java Tutorial says, because they make the surrounding class implement the Listener interface,and use addActionListener(this). It is a convenient shorthand avoiding the complication of writing a separate class for the Listener, but in my opinion and those of several other contributors to these fora, separate classes make code easier to manage.
If you want to see a bit about Listeners, a few old posts will introduce you to the ideas: here, here, and here.

You may not need these links at this stage, but I hope you find them of use when you do.
Ra Carter
Ranch Hand

Joined: Jul 30, 2005
Posts: 96
i think it is probably easier to go the other way. a lot of companies will take java programmers with limited .net experience with the idea that it will not be a hard transition.

it might be harder for you to go from .net to java (which was the intention all along by the way).

as far as differences in the actual languages, it is like comparing... oh i don't know... say macintosh apples to granny smith apples. now look i am no fruit aficionado but my point is they are both apples if you gave them to me i wouldn't know the difference.

so if you ask me the biggest difference between java and .net is really just the vendors. there are some syntax differences to keep you occupied but your biggest transition problems will be how to compile and package your program, what ide to use, what is the right app server, the right os, etc. where as in .net you always had the right answer so long as your answer was Microsoft.

now i will go into my tangent and say Microsoft is a very smart company. although the mono project exists for open source vendors, it seems like they operate without the support or approval of microsoft. to me it seems like most .net developers don�t even care about mono and how many production grade applications use log4net, nhibernate, or nant? the bottom line is that if you see a site hosted in .net it is most likely running on a windows server using iis and was programmed on visual studio. There is most likely a sql server database in there as well. and at that it is also probable that the entire company is working on a homogenous windows environment.

and that was the whole reason c# and .net was invented for in the first place.

Sun on the other hand is STUPID. even though they invented and maintain java, i can write my code on windows, use open source libraries from apache, create desktop apps for mac, and deploy web sites on linux servers using ibm software. i don�t think i personally ever purchased anything from sun actually. why would i? and the fact that most of the java libraries are object oriented only makes it so much easier to switch vendors. all i can say is that they are stupid and if you like to complicate your life with a wide variety of choices thereby allowing multiple vendors to compete for your business by making better and cheaper products then go right ahead my friend and don�t take advantage of .net.

[ March 14, 2007: Message edited by: Ra Carter ]
B Dent

Joined: Mar 14, 2007
Posts: 2
Thanks for all the responses. I did a little more research and came across a Headfirst Java book which has been great so far. Looks like they also have Headfirst Servlets & JSP and Headfirst EJB which both say you can pass cert when you are finished the book(s), so I guess I should be good to go.
pete stein

Joined: Feb 23, 2007
Posts: 1561
I don't think that Sun has the marketing muscle or overall bulk to pull off a proprietary language a l� Microsoft. By putting Java in the open domain, and by giving continued support to the language, Sun has assured its success. Given this success despite these constraints, Sun looks pretty smart to me.
[ March 14, 2007: Message edited by: pete stein ]
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14917

.NET and Java are a lot alike:

Programming language: C# / Java
Runtime environment: CLR (Common Language Runtime) / JVM (Java Virtual Machine)

ASP corresponds to JSP in the Java world.
SQL Server is a database; you can use SQL Server from Java or any other database you like (some free to use databases are MySQL, PostgreSQL). Apache Derby is an open source database that is included with JDK 6.

To start learning Java, see the links in my signature.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Switching from .NET to JAVA help...
It's not a secret anymore!