Do you think IIT Guwahati certified course can help you in your career?
No
Introduction
Hey Ninja🥷! Today we will be looking into setting-up your preferred IDE . We all have used a lot of IDEs like VSCode, Codeblocks, and even some online IDEs like the ones available in Coding Ninjas Studio. During the coding journey, we choose one or two IDEs as our preferred IEDs. Ever wondered about setting-up your preferred IDEs? Well, let's see.
About Play
Play is a Java framework that helps you in setting-up your preferred IDE. Did you know working with Play is very easy?. We don't even need a sophisticated IDE because Play automatically compiles and refreshes the modifications we make to our source files, so we can efficiently work using a simple text editor.
However, many awesome features like auto-completion, on-the-fly compilation, assisted refactoring and debugging are there for us which levels up our creativity if we use a modern IDE of Java or Scala.
Let’s have a look at various IDEs available to us like Eclipse, IntelliJ IDEA, NetBeans, ENSIME.
Eclipse
Eclipse is a Java-based development environment that is available for free for its developers. It has gained popularity among developers for its plugins. Sbt is an Open source development tool that helps during development in Scala and Java.
Setting-up your preferred IDE using sbteclipse
Integration with Eclipse requires sbteclipse. We always use the most recent version of our project/plugins.sbt file. We can also follow sbteclipse docs to install it globally.
We must compile our project before running the eclipse command. By adding the following setting in the build.sbt, we can force the compilation of the project while the eclipse command is running:
// Before generating Eclipse files, we should compile the project, so
// that generated .scala or .class files for displays and routes are present there
EclipseKeys.preTasks := Seq(compile in Compile, compile in Test)
If we have Scala sources in our project, we should install Scala IDE. Instead, if we want to continue without installing, then we can set the following build.sbt (assuming we have only Java sources and no Scala sources):
EclipseKeys.projectFlavor := EclipseProjectFlavor.Java
// We Use .class files instead of generated .scala files for views and routes
EclipseKeys.createSrc := EclipseCreateSrc.ValueSet(EclipseCreateSrc.ManagedClasses, EclipseCreateSrc.ManagedResources)
Generating Configuration
We use the eclipse command, after configuring sbt-eclipse, to transform a Play application into a working Eclipse project.
[ninjas-first-app] $ eclipse
If we want to use the available source jars, we can use the following code, but this may take more time, and a few sources might be missing:
[ninjas-first-app] $ eclipse with-source=true
If we use sub-projects with segments, we will have to set skipParents properly in build.sbt:
EclipseKeys.skipParents in ThisBuild := false
Or in the sbt shell, we can enter:
[ninjas-first-app] $ eclipse skip-parents=false
We must import the application into our Workspace with the help of the URL-File/Import/General/Existing project….
To debug, we start our application with sbt -jvm-debug 9999 and run in Eclipse. We right-click on the project and select Debug As and then choose Debug Configurations. In the Debug Configurations dialogue, we again right-click on Remote Java Application and choose New. Here we change Port to 9999 and then click Apply. From now on, we can click on Debug to connect the running application. Terminating the debugging session will not prevent the server.
Here it is recommended to run our application using ~run to enable direct compilation whenever any alteration is made in the file. In this way, scala template files are auto-discovered when we create a new template in view and auto-compiled when the file changes. If we use the usual run, we must hit refresh on our browser each time.
In case we make some significant changes to our application, such as changing the classpath, we have to use Eclipse again to regenerate the configuration files.
It is not advisable to commit Eclipse configuration files while working in a team. To make that sophisticated,, we may add the following lines to our .gitignore file:
/.classpath
/.project
/.settings
The generated configuration files carry absolute references to our framework installation. These are specific to our installation. When we work in a team, each developer must keep his Eclipse configuration files private.
So far, you have studied how you can use Eclipse for Setting-up your preferred IDE. Let’s have a look on how IntelliJ IDEA may help us in achieving the same.
IntelliJ IDEA
Intellij IDEAhelps us in creating a Play application without the help of a command prompt. We don't need to configure anything outside the IDE. The sbt development tool helps us a lot in this case. It downloads appropriate libraries, resolves dependencies, and even builds the project by itself. Sbt tool assists you and is very efficient in setting up your preferred IDE.
Before creating a Play application in IntelliJ IDEA, we have to install and enable the latest Scala Plugin in IntelliJ IDEA. Even if we don't use Scala, the plugin will help us with the template engine by resolving the dependencies. To do so, we can follow the undermentioned steps.
To create a Play application:
We open the New Project wizard, select sbt under the Scala section, and then click Next.
Here we have to enter our project's information and then click Finish.
We can also import an existing Play project.
To import a Play project:
We open the Project wizard and then select Import Project.
After that, we select a project we want to import in the open window and then click OK.
On the wizard's next page, we select Import project from the external model option, then choose sbt project and click Next.
On the wizard's next page, we select additional import options and at the end, click Finish.
We look at the project's structure and make sure that all necessary dependencies that will help you in setting-up your preferred IDE are downloaded. We can also use different code analysis features such as code assistance, navigation, on-the-fly, etc.
We can see the output of our created application in our browser with the help of http://localhost:9000.
To run any Play application:
We create a new run configuration by following the steps:
Click on the Main menu
select Run
select Edit Configurations
A pop-up will appear. Click on the + to add a new configuration
From the list of configurations, we choose "sbt Task."
In the "tasks" input box, we put "run."
Finally, we apply changes and select OK.
Now we can choose "Run" from the main menu and run our application.
Using default Run/Debug Configuration settings, we can quickly start a debugger session for a Play application.
Now suppose we encounter some problem while running our project. So, we will need to look at the source code to make changes.
Navigating from an error page to the source code
The Play.editor configuration option Play creates hyperlinks in an error page. In this way, we can link to runtime exceptions that are thrown when Play is running in the development mode.
We can easily navigate from error pages to the source code directly by using IntelliJ's "remote file" REST API with the built-in IntelliJ web server on port 63342.
Writing the following line in application.conf to provide hyperlinks to assist you in setting-up your preferred IDE:
At present, Play does not have native NetBeans project generation support, but there is a Scala plugin for NetBeans, which can help us with both Scala language and sbt.There is also an sbt plugin that we can use to create the NetBeans project definition. It will help you in setting-up your preferred IDE.
ENSIME
ENSIME is a tooling project that is now regarded as a go-to mode for Scala editing in emacs by most developers. It is an awesome tool and has pioneered community-oriented development in the domain of scala.
Let’s briefly look at how we can generate its configuration.
Generating configuration
We can edit our project/plugins.sbt file and then add the following line. We should always first look for the presently running version of the plugin:
From Emacs, we execute M-x ensime and follow the on-screen instructions.
That's all there is to it. It would be best if we now get type-checking, completion, etc., for our Play project. If we add new library dependencies to our Play project, we'll need to re-run "ensimeConfig" and re-launch ENSIME.
Eclipse is an integrated development platform used in computer programming. To customize the platform, it contains a base workspace and an extensible plug-in system. It ranks second on the list of most popular JAVA IDEs.
What is ENSIME?
ENSIME, or the ENhanced Scala Interaction Mode for Emacs, is a tooling project which unites hundreds of Free Software contributors from different backgrounds. At its peak, 10% of Scala developers were using ENSIME as their IDE for Scala.
What is IntelliJ IDEA?
It is an integrated environment developed in JAVA. Computer software written in Java, Kotlin, Groovy, and other JAR-based languages is developed using IntelliJ IDEA. Developed by JetBrains, IntelliJ IDEA is available as an Apache 2 Licensed community edition and for commercial use in a proprietary edition.
Conclusion
Congrats! you made it to the end of the article on setting-up your preferred IDE. We have a lot of options to choose from but we prefer only one or two IDEs, the ones which give us the best coding experience.
Here are a few key websites that will aid in setting-up your preferred IDE:
But suppose you have just started your learning process and are looking for questions asked by tech giants like Amazon, Microsoft, Uber, etc. In that case, you must look at the problems, interview experiences, and interview bundle for placement preparations.
We hope you have a good experience going through our article on setting-up your preferred IDE.
Nevertheless, you may consider our paid courses to give your career an edge over others!
Upvote our Hibernate and Spring Integration blog if you find it helpful and engaging!