Going from C# to Java

Klogg

Centurion
Joined
Oct 7, 2003
Messages
104
Hey, I was wondering if any of you know of a good web site or something where I can learn Java based on my knowledge of C#. My reason for doing this is because my class this semester is being taught in C#, but my classes next semester are being taught in Java. I want to learn the differences between the two languages over Christmas break so I will be more prepared to learn in next semester's classes without having to learn Java at the same time. It's pretty easy to find places to learn C# based on a knowledge of Java, but not the other way around. I guess if all else fails, I'll have to read backwards... or something like that.
 
Yeah, let me know if you find something...need that myself and while I've figured out the syntax (since it's 90% the same) the environment and how to do things is a source of headaches (deploy a project, create a 'windows' like app, etc.) ...Just doing straight class objects isn't an issue...it's doing anything GUI related or deployment related that is killing me - plus finding decent help files that include namespaces and related functions. Walk away from Microsoft for 10 minutes into that other world and you'll discover very quickly why Microsoft has the market share it does! :)
 
I emailed my professor, and he said that the best option was to use the Eclipse IDE, that I would pick up the differences between the two languages quickly, and that the real difference is not being able to use Visual Studio .NET. That's all I've got so far. I haven't figured out how to use Eclipse yet.
 
Yeah... I have Eclipse...imagine Visual Studio without Forms, Web Forms, Controls, and anything else that makes development easy. Eclipse is a nice IDE if you know the libraries already, but I don't, as well as yourself, so I think your professor is being a little optimistic. Could you or I design a windows program or asp.net application without the designers, I'm assuming you can, and I know I can...is it easy or fun? Heck no! That's what the designers are for. Ask your professor what you have to download to do designer web forms and windows forms (deployment too), I'm curious what he has to say about that.

My big issue is that for all the stuff out there on Java, there's not very useful (that I've found at least). No, 'hey, you're trying to do this, you need to: blah blah blah) - a forum like this, or like code project, or heck MSDN would be a start - the help files that I've seen are way to technical and don't provide an overview.

I'd like to keep in contact with you about this as it seems we're both going down the same road...mine is work related, don't know about yours, but we seem to have the same goal.
 
There's this web site called SkillSoft that I have access to because I'm a student at my university, and there are lots of online books there. I searched and found some books on using Eclipse, and they listed some different options for creating forms. So I emailed my professor last night and asked which stuff I should download. When he replies, I'll let you know what he says. I seem to be getting closer to figuring this out, especially now that I have those books online to teach me how to use Eclipse and Java.
 
I've found in Eclipse that if you can automatically download some plugin by

I also found this sun website pretty useful:
http://java.sun.com/developer/onlineTraining/Programming/BasicJava1/index.html#contents

Has a nice intro and most of it is just a familiarization of the differences between the two platforms. The thing that is really throwing me is they don't have properties - they have methods (which underlying in the IL is the same thing, but at the level we work with it's a little more intutive):

For example in VB or C#:

Visual Basic:
Public Property Text As String
      Get
            return myText
      End Get
      Set (Value As String)
            myText = Value
      End Set
End Property
C#:
public string Text
{
       get
       {
           return myText;
       }
       set
       {
           myText = value;
       }
}

Is the following in Java:
Code:
public string getText()
{
      return myText;
}
public void setText(string value)
{
      myText = value;
}

And that will just drive me absolutely nuts! A property is a property to me, not a method that I threw get or set in front of (and by the way that's just coding practice...you don't have to use 'get' or 'set' --- you could call it gText and sText. Loss of intutiveness for sure.

Another thing that is fun is how events are wired up:

Code:
if (btnTest == null) {
	btnTest = new JButton();
	btnTest.setText("Click Here");
	btnTest.addMouseListener(new java.awt.event.MouseAdapter() {
		public void mouseClicked(java.awt.event.MouseEvent e) {
			lblMessage.setText("Button Clicked");
		}
	});
}

That's right...you add the method and the event in the same block of code. So I guess if you have multiple objects that raise the same event you have to make an extra function and have all the event handlers call that method...lot's of extra code instead of having all the events point to the same handler.

And another fun thing...once you get into doing forms...apparently they do everything in panels...can't figure out for the life of me to how to get a button to position at (20, 110) and be 100 pixels wide and 20 pixels tall.
 
I don't know many details from my (approximate) total of one hour programming Java, but let's address those short-comings of Java you guys mentioned.

bri189a said:
The thing that is really throwing me is they don't have properties - they have methods (which underlying in the IL is the same thing, but at the level we work with it's a little more intutive):
Sun has a standardized API for properties, JavaBeans. In order to implement properties in Java, a class must implement a Serializable or Externalizable interface. The Java class Introspector retrieves a BeanInfo interface with property information. That's the jist of it, but there are lots of details that make my head hurt. In other words, Java has a standard for properties, but they are more intended for IDE purposes and are very cumbersome for hand-coding purposes.

PlausibleDamp said:
From what little I remember of Java you will also have to make do without enums and delegates as well.
Enums are there in Java. As far as delegates, go, the closest thing in Java is the Reflection class "Method" which can be passed around and invoked similarly to a delegate. Still, this would be just like passing around System.Reflection.MethodInfo classes as a sorry excuse for a delegate. The "correct" way of achieving function pointer-like behavior in Java is through interfaces.


Um... yeah, I still think that I'm sticking with .Net. The spirit of open-source and cross platform is great and all, but I have to concede; Microsoft did a good job of making .Net intuitive and managable.
 
I'm not going away from .NET - I just need to learn Java for day job purposes...my full time job is still .NET, I'll just need to interact with Java more - believe me, I wouldn't take a step backwards! :)
 
The easiest IDE for Java programming that I have found is NetBeans (www.netbeans.org). I am using NetBeans 5.0 Beta at home and it is almost as easy to build GUI and web pages as Visual Studio. It is freely available for download through an opensource license.

Todd
 
My professor recommended using Swing for the GUI. I might check out that NetBeans thing, though. It looks promising. Has anyone else tried it?
 
I learned Java in college with jCreator. Awful IDE. It's like notepad with a list of files on the side and keywords being highlighted with an option to compile.

I was comming from VB6 at the time.

Since then I've just recently begun tutoring a woman in Java and using jBuilder by Borland. I havn't tried the newest version which released simultaniously as VS2005, but the other version is free for commercial and non-commercial use. It's not quite Visual Studio quality, but it's pretty damn good and has intellisense to some degree.

The only drawback I have is that there is no intuitive way to build a GUI app. I say intuitive because it's probobly easy once you know how. I ended up destroying a project by dragging items onto a form. That uses Swing and I think an option of something else.

I've heard great things about this netBeans and if I have to tutor her again next semister (she'll be working without a teacher... great) I'll be giving that a testdrive.

I've heard good things about it from a .Net developer at work, another non-programming forum, here and a friend who is into programming in Java.
 
tfowler said:
The easiest IDE for Java programming that I have found is NetBeans (www.netbeans.org). I am using NetBeans 5.0 Beta at home and it is almost as easy to build GUI and web pages as Visual Studio. It is freely available for download through an opensource license.

Todd
Klogg said:
My professor recommended using Swing for the GUI. I might check out that NetBeans thing, though. It looks promising. Has anyone else tried it?
Netbeans uses Swing and exposes the JavaBeans properties of the Swing classes. The combination of Netbeans and Swing brings you an almost-.Net style IDE. Until you begin to code and find that properties are not accessible through code the way they are in .Net, and you have to search for functions to do what you need, which aren't necessarily get/set function pairs.
 
hi,
if you know that Java and C# was developed based on C++ :) , so it's easy for you to learn java or c# after have knowledge of the rest !
:) !
 
There are a few key differences between C++ and Java/C#. The first and most obvious is that C++ is fake object oriented while C# and Java are actuall object oriented. The next biggest thing would the the Garbage Collection/lack of pointers in [managed] C#/Java. I think that those differences are big enough to make it confusing if you are coming from C++. C# to/from Java shouldn't be that bad...

Swing? HA! Swing easily creates the ugliest forms I have ever seen. Those buttons are just gnarly looking. That's the one huge drawback to using Java -- people know when they are running a Java app becuase it looks drastically different from every other form you run. And it's different not in a good way like a skin.
 
Depending on... something (I don't know what) swing can use XP styles (my NetBeans apps used Xp Styles), but yeah, I've seen some ugly Java apps.

And C#/Java aren't based on C++. They use C-style syntax and are object oriented, but these aren't unique to C++. The biggest difference between C# and Java would probably be the standard libraries.

As far as C++ being "fake object oriented," I don't know if that is the best way to put it. It might not as traditionally object oriented, and the exectuables may not be self-describing (a lack of type definition metadata), but within a single program I would say that it is possible to write code in a completely object-oriented manner. You have your encapsulation, inheritance, data-hiding, polymorphism, yada yada yada. I'm not sure that object-oriented implies garbage collection or a lack of pointers, but if there are any other enormous differences, they wen't over my head.

And just a note, this thread was over a month old. I personally don't mind, but the posting guidelines do ("Threads that have been inactive (no new posts) for one month or more should be considered archive-only and should be left alone (except by the thread starter).").
 
I believe the person who posted the message after a month was a first time poster, their post count is at one as of my posting. But yes, guidelines are just that, and should be observed except by people like us three who if asked would probably come up with some excuse for making additional posts... ;)
 
I agree, we probably should continue this post for quite some time just to keep it current. Java is a royal pain in my rear so anything new that has come up in here has been quite helpful. Rules are meant to be broken :)
 
Back
Top