Eclipse New Java Project

1 view
Skip to first unread message

Scottie Marberry

unread,
Aug 3, 2024, 12:24:35 PM8/3/24
to staratultec

Select the Project Layout which determines whether there would be a separate folder for the source codes and class files. The recommended option is to create separate folders for sources and class files.

The package explorer shows the newly created Java project. The icon that represents a Project is decorated with a J to show that it is a Java Project. The folder icon is decorated to show that it is a java source folder.

I am working for a software editor and we mainly use Java as backend language. I use to work with Eclipse since around 2010, only for Java projects. Here is my journey and a quick comparison of the tools.

First of all I need to inform that I am actually Product Owner and not anymore a full-time developer. So I am still looking at Java source code project, but with a different level of usage than before.

VSCode is relying a lot on extension. Each extension add a little extra power to the tool. So the initial text editor can be compared with a fully featured IDE once the right extensions have been installed.

Eclipse is relying on a workspace concept where you import Java projects. My main concern with this approch is around multi-modules Maven projects : once you add or remove a module, Eclipse is lost and you need to import again the missing module.

It's not a big difference but for me it is more easy to switch between projects. I do not loose anymore time to import projects, I just open the right folder. There is also a workspace system in VSCode to open multiple folder at once, it may be useful if you work on multiple projects at the same time (front and back for example).

Git is directly available in VSCode. I have never rely on any Git addon in Eclipse, as I found some products buggy. So I was relying only on the Git command line. I still rely a lot on the command line but I am happy to see this very good integration of Git directly into the product.

And you have some indicator directly in the editor (green if new line, red if removed lines...). I have never see this kind of indication inside Eclipse. Probably I have never installed the right extension ;)

One month after VSCode installation and first test on Java projects, I realize that I haven't opened anymore Eclipse. Just today to make a screenshot...
I have not yet speak of the performance too. I have a decent MBP and Eclipse take always a couple of seconds to startup. VSCode start in less than a second.
Last, I am not only coding in Java but also Javascript. I have originally installed VSCode to replace Atom editor for my JS projects... So I am happy to be able to use a single tool for all my programming needs. It's faster and I am more comfortable to use a single tool for coding.
So just an advice: get a try on one of your Java project, you may be surprised to change your habits !

I tried it, but still think it falls behind most of the good Java IDE's (which I never considered Eclipse to be).
I like vscode for pretty much everything other than java or c/c++, .net, where the best of breed tooling is far far ahead (intellij and visual studio imho).

I have developed both in Eclipse and Intellij and I didn't find Intellij better than Eclipse in any significant way.
May I ask why do you find Intellij "best of breed tooling" and don't consider Eclipse a "good Java IDE"? I am not being sarcastic, I am genuinely curious.
PS: Just today I installed Eclipse 2020-9 and I am definitely finding it at par with Intellij which comes at a cost of $150-200.

IntelliJ lately started freezing and slowing down, but this is in regards to Kotlin. Haven't used Java in couple of months but I guess it would be the same. For some scripting stuff like Apache Camel K, I used VS code for Groovy but I guess having 1 file for each integration would better be with VS Code than IntelliJ as you don't care about indexing and such in these scenarios.

I am an old bloke, I started with Borlands JBuilder, then moved to Eclipse when it came out and eventually, about 15 years ago, I moved to IntelliJ, mainly because of its great tooling support for Grails. I also use VSCode for my JavaScript projects and I would love to switch completely, especially because VSCode feels so lightweight, but it doesn't really work for me.

I keep my workspace directory that holds project directories. I can have the workspace directory pulled in and VSCode just works without opening specific directories if I want Eclipse style workspace.

There is also the benefit of developing in a virtual environment. I'm honestly not sure if eclipse has this functionality, but with the VSCode remote ssh plugin you can remote into your virtual machine (vagrant box or what have you), develop through VSCode on the host machine and keep your dev environment isolated.

Yes you can transfer eclipse programs from ubuntu to windows and the reverse too.For transferring files from windows to ubuntu you need to export you project from Windows and then import the project to Ubuntu.

Exporting File->Export->General->Archival file and tick the project or files(All files related your project must be ticked) which you want to exportand select where you want to save the files and you also need to name the file.Now you

Maybe the .classpath file in your project directory was not copied as it would be a hidden file under Windows. In Linux anything with it's name starting with . is automatically considered hidden. Do you get those errors even if you create a new Java project in Eclipse and then copy the src folder to the project?The .classpath file tells Eclipse from where to load user-classes besides existing classpath(s). So you may get unresolved class problem without it.

The other answers answer you question, but based on your snapshots, I would bet that your project is configured to use a java runtime/SDK at a hard coded locattion. Try and have a look at your project properties, in the Java Build Path/Libraries/JRE System Library, or in Java Code Compiler. If you see windows-like path, it's not good...

Select Java Build Path on the left, then open the Libraries tab, and develop the JRE System Library item. If you see things like /usr/lib/jvm... you're good. If you see things like c:... that's your problem: the project tells eclipse to look for the java software development kit in a location that is windows-specific.

I can run locally now but i have to run mvnw spring-boot:run in windows terminal when i run the project the first time. Seems to me that it doesnt run the eclipse kotlin with spring plugin properly.
However each time i edit kotlin code, i have to rerun the command again. Basically seems to me that eclipse finds sources when maven compiles, but cant compile it himself

I first learned Vim in university and, since then, it has been a welcomecompanion for the majority of my software engineering career. Working withPython and Go programs felt natural with Vim and I was always felt productive.Yet Java was always a different beast. Whenever an opportunity to work withJava came up, I would inevitably try Vim for a while, but fall back to IntelliJand the IdeaVim plugin to take advantage of the rich language features afull-featured IDE can give you.

The nice thing about this diagram is that it is not specific to Java. Once youunderstand how to get things working for one language, you can repeat theprocess for any language that implements the language server protocol and debugadapter protocol. For Java, we use Eclipse JDTLS as the language serverimplementation, andvscode-java-debug as thedebug adapter (which leverages java-debug).

If you are working through this guide to setup Noevim as a Java IDE, it iseasiest if you add a single plugin at a time, understand how to configureit, how to use it, and what functionality it provides, and then add moreplugins. This way you get a better sense of what changes you are making to theNeovim environment without getting overwhelmed.

Neovim supports the Language Server Protocol (LSP) out of the box, acting as aclient to LSP servers and including a Lua framework called vim.lsp forbuilding enhanced LSP tools. The general advice for getting started with thebuilt-in client is to usenvim-lspconfig, which providesdefault configurations for many differentlanguages.

Some languages have plugins supporting richer LSP functionality. Java is one ofthem. nvim-jdtls providesextensions to the built-in LSP client like organizing imports, extractingvariables, and code generation. Both nvim-lspconfig and nvim-jdtls use theclient built into Neovim, the main differences are that nvim-jdtls adds someadditional handlers and functionality, as well as simplifying theconfiguration. One of the advantages of using nvim-jdtls is that, once up andrunning, you can use the same Neovim keybindings and client functionality thatyou may already be using for other lanuages without having to learn aplugin-specific way of interacting.

The following diagram, from the nvim-jdtls documentation, shows how itdiffers from nvim-lspconfig. Both use the Lua bindings already built-in toNeovim, but are setup and configured slightly differently.

Configuring nvim-jdtls can be intimidating. The following exampleconfiguration is commented to show how I setup nvim-jdtls on my developmentmachine. Most of the options come directly from the Eclipse JDTLSdocumentationand are specific to jdtls.

To start jdtls using this configuration, place the file above in the folder.config\nvim\ftplugin\java.lua. Neovim will automatically execute this codewhenever a file of type Java is loaded into the current buffer. (ftpluginis shorthand for filetype plugin).

Although the configuration seems like a lot, it can be broken down into a fewsections. First, we create the required keymappings for the LSP client. Then wespecify the options to pass to eclipse.jdt.ls, and lastly, we set the commandto use to launch eclipse.jdt.ls. Once we get that configuration in place, wepass it as a parameter to jdtls.start_or_attach, which will start thelanguage server or attach to an existing running instance if the server isalready started.

c80f0f1006
Reply all
Reply to author
Forward
0 new messages