Going from C# to Java

Klogg

Well-known member
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 semesters classes without having to learn Java at the same time. Its 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, Ill have to read backwards... or something like that.
 
Yeah, let me know if you find something...need that myself and while Ive figured out the syntax (since its 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 isnt an issue...its 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 youll 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. Thats all Ive got so far. I havent 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 dont, 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, Im assuming you can, and I know I can...is it easy or fun? Heck no! Thats what the designers are for. Ask your professor what you have to download to do designer web forms and windows forms (deployment too), Im curious what he has to say about that.

My big issue is that for all the stuff out there on Java, theres not very useful (that Ive found at least). No, hey, youre 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 Ive seen are way to technical and dont provide an overview.

Id like to keep in contact with you about this as it seems were both going down the same road...mine is work related, dont know about yours, but we seem to have the same goal.
 
Theres this web site called SkillSoft that I have access to because Im 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, Ill 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.
 
Ive 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 dont have properties - they have methods (which underlying in the IL is the same thing, but at the level we work with its a little more intutive):

For example in VB or C#:

Code:
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 thats just coding practice...you dont 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");
		}
	});
}

Thats 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...lots 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...cant 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 dont know many details from my (approximate) total of one hour programming Java, but lets address those short-comings of Java you guys mentioned.

bri189a said:
The thing that is really throwing me is they dont have properties - they have methods (which underlying in the IL is the same thing, but at the level we work with its 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. Thats 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 Im 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.
 
Im not going away from .NET - I just need to learn Java for day job purposes...my full time job is still .NET, Ill just need to interact with Java more - believe me, I wouldnt 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. Its 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 Ive just recently begun tutoring a woman in Java and using jBuilder by Borland. I havnt tried the newest version which released simultaniously as VS2005, but the other version is free for commercial and non-commercial use. Its not quite Visual Studio quality, but its 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 its 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.

Ive heard great things about this netBeans and if I have to tutor her again next semister (shell be working without a teacher... great) Ill be giving that a testdrive.

Ive 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 arent necessarily get/set function pairs.
 
hi,
if you know that Java and C# was developed based on C++ :) , so its 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 shouldnt be that bad...

Swing? HA! Swing easily creates the ugliest forms I have ever seen. Those buttons are just gnarly looking. Thats 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 its different not in a good way like a skin.
 
Depending on... something (I dont know what) swing can use XP styles (my NetBeans apps used Xp Styles), but yeah, Ive seen some ugly Java apps.

And C#/Java arent based on C++. They use C-style syntax and are object oriented, but these arent 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 dont 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. Im not sure that object-oriented implies garbage collection or a lack of pointers, but if there are any other enormous differences, they went over my head.

And just a note, this thread was over a month old. I personally dont 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