Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# moving to Java, just need to know a few things

I'm making the leap to android applications and java development and am trying to find my way around the java world, specifically eclipse. I am an experienced C# .Net developer and everything looks familiar but I need to get a few fundamentals.

I just need to have a few things clarified relating C#/Visual to Java/Eclipse:

1: Are Java Projects/Packages/Classes the equivilant to C#/VS Solutions/Projects/Classes?

2: In C#/VS my project "ProjectName" will compile down to ProjectName.dll that I can then reference, how does this work in the Java world?

3: In C#/VS you have different project types, console apps, win form apps, class library etc, whats the equivalent in Java if any?

I think thats enough for now.

Any help would be appreciated.

Cheers.

like image 812
David Avatar asked May 14 '11 21:05

David


2 Answers

  1. Yes/No/Yes. Packages in Java are analogous to Namespaces in .NET. Unfortunately, .NET does not have the strict file layout requirements for its namespaces. So, while Java requires com.yourcompany.yourclass to exist as com/yourcompany/yourclass.java, .NET can have com.yourcompany.yourclass exist anywhere in the file tree.

  2. In Java, you are compiling everything into Jar files. This is analogous to compiling to a DLL or EXE.

  3. It's completely IDE specific. These are just conveniently preset templates to help you get started without requiring you, the developer, to setup all of your dependencies. I'm pretty sure each one is represented almost verbatim under Eclipse project creation.

like image 184
pickypg Avatar answered Sep 29 '22 22:09

pickypg


1: Are Java Projects/Packages/Classes the equivilant to C#/VS Solutions/Projects/Classes?

Java Projects -> C# Projects and solutions (depending on the type of Java project .. for example a single project can collect together different projects in Java)

Java Packages -> C# Namespaces

Java Classes -> C# Classes

2: In C#/VS my project "ProjectName" will compile down to ProjectName.dll that I can then reference, how does this work in the Java world?

In Java there are no .dll files which are windows specific. Libraries and applications are packaged in JAR files normally and they can be added to the project build path when you required them. In order to package them, you need to export a project to a JAR file. Jar files can also be packaged to be runnable and thus perform similarly to .exe files as well.

Hope this helps.

like image 28
aseychell Avatar answered Sep 29 '22 20:09

aseychell