开发者

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

开发者 https://www.devze.com 2023-03-06 11:26 出处:网络
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 f

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.


  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.


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.


Well, there are many different ways to make a 'solution/project' in Eclipse, but I think that you can generally think of Eclipse projects as VS solutions. C# namespaces would be equivalent to Java packages, and classes are classes in both cases.

A Java .jar file is equivalent to a .dll from C#.

All apps with a 'main' function in Java can be used as console apps. To make a graphical app you would use something with a Windowing Toolkit (such as Swing or AWT). And a library would be Java code that you put into a .jar. Eclipse has a pluggable interface, which allows for plugin developers to create new ways to organize projects. If you are looking for something to help you layout a graphical interface, there is likely a plugin that can assist you with that.

Also worth note is that there are other IDE's to use with Java. You might also want to take a look at IntelliJ IDEA and NetBeans.


Check the Java Tutorials site from Oracle. Under 'Trails Covering the Basics', the links 'Learning the Java Language' and 'Deployment' should help answer your questions.

0

精彩评论

暂无评论...
验证码 换一张
取 消