Tag Archives: intellij

Docker for Java Developers with IntelliJ IDEA Webinar Replay

Video recording from Docker for Java Developers webinar is now available:

Here are answers to the questions asked:

  • What do you think of Kubernetes compared to Docker and Docker Swarm? Kubernetes or Docker Swarm? Which way to go?

    It depends 😉

    Docker Swarm has a much simpler learning curve as opposed to Kubernetes. Kubernetes is very opinionated but can be very powerful once you understand how it works.

    Some of the points worth considering are:

    • Easy to setup/start
    • Need to learn new concepts or aligned with Docker
    • How can it be aligned with your existing workflow
    • Single or multiple master
    • Support for multiple clouds
    • Cluster across multiple clouds
    • Dynamic scaling up/down
    • Rescheduling containers on node/container failure
    • Pluggable scheduler strategies (if you want to go fancy)
    • Service discovery
    • Persistent volumes

    If this question was asked a few months ago, then Kubernetes would have been the obvious choice. But Docker Swarm is really cranking out releases and features and has caught up well. Check out Docker Swarm Exceeds Kubernetes Performance at Scale. Hackernews has some interesting discussion on this topic as well. Also read Evaluating Container Platforms at Scale.

    In addition, you should also look at Mesos+Marathon or DC/OS.

    Here are some blogs to get started:

    • Couchbase cluster on Docker Swarm using Compose and Machine
    • Kubernetes Cluster on Google Cloud and Expose Couchbase Service
    • Kubernetes Cluster on Amazon and Expose Couchbase Service
    • Couchbase on DC/OS and Amazon
  • What is the best practice to develop against a docker WildFly container if you do not want to bundle the WAR file after each change but use an exploded archive instead in order to just repackage static resources for example?
    Docker allows mapping directories on your filesystem as volumes in the container. This can be used to develop your application against a WildFly container without the need to be bundle the WAR with each change. This is explained in more detail at Deploy to WildFly Docker from Eclipse.
  • Does IntelliJ Idea support native docker on Mac OS/Windows?
    Andrey: Not yet but it’s on the roadmap.
  • What are pros and cons of providing environment variable vs link like consul:consul?

    Docker Links are legacy and so environment variables and Docker Networking are the recommended way to build any new applications. Read more details in another answer below.

  • How do we attach a debugger to a Java process running in a container?

    Read this great blog entry by Daniel Bryant on Debugging Java Applications running in Docker.

  • What is the relation between Docker and Vagrant? Can both work together? Is docker a substitute of Vagrant?

    Docker and Vagrant solve different problems.

    Vagrant allows you to provision Virtual Machines independent of the host machine. This is done by using a hypervisor, such as VirtualBox. The definition for the VM is stored in a Vagrantfile, and defines how to setup the VM and what scripts to provision the environment. These VMs can be created on Linux, Windows or Mac.

    Docker allows you to create containers. It is a native Linux technology based upon lxc and coming to Windows Server 2016 this Summer. Docker for Mac provides development environment for Mac.

    If you need to provision a Docker Engine, then you can create a Vagrantfile that provisions Ubuntu or CentOS using Virtual Box. Then run apt get or yum install scripts to install Docker Engine. If a new version of Docker Engine is available, then you are responsible for updating the Vagrant image as well, or run the script again.

    Another option is to use Docker Machine and use VirtualBox driver to create a machine that will have Docker Engine installed. The docker-machine script has commands like upgrade that simply upgrades the Docker Engine.

    Some more interesting discussions are at StackOverflow and Quora.

    To make this whole equation further interesting, Vagrant can be backed by Docker containers instead of VMs!

  • Docker tool window is missing in my IntelliJ IDEA 15. Plugin is installed.

    Andrey: The separate tool window was added in 2016.1. Before that Docker was a part of the Application Servers tool window.

  • Is it possible to change index.jsp and see the change in the browser without building the image again? In the spirit of update resources action in IntelliJ IDEA?

    Andrey: Sounds like a great idea. Please submit it as a feature request to tracker: https://youtrack.jetbrains.com/issues/IDEA.

  • Is there a performance increase for using xhyve/Hyper-V over VirtualBox?

    Docker for Mac runs Docker Engine in Alpine Linux distribution on top of xhyve Virtual Machine for Mac OS X or on Hyper-V on Windows. xhyve is built on Hypervisor.framework in OS X 10.10+. Some of the primary advantages of using a native technology as opposed to a Type 2 hypervisor is native look-and-feel, better performance, and better volume management.

    Read more details in (3-months old blog) xhyve vs VirtualBox driver benchmarks. This area is fast evolving and keep an eye on blog.docker.com for more details.

  • In Docker Compose, how do I update only one container, does it lose the “link” do I need to redeploy everything?

    Docker Links are now legacy. It’s highly recommended to migrate your application to use Docker Networking. The main difference between Links and Networking are:

    1. Connect containers to each other across different physical or virtual hosts
    2. Containers using Networking can be easily stopped, started and restarted without disrupting the connections to other containers
    3. You don’t need to create a container before you can link to it. With Networking containers be created in any order and discover each other using their container names
  • How can one expose a host port to a container running on the host?

    Ports in a container are exposed on the host using -p with docker run. Ports on the host can be accessed using <host-ip>:<port> directly.

  • Official Java Docker image (OpenJDK-based) is not TCK certified. What do you suggest in this case?
    OpenJDK is the Reference Implementation of Java SE and so is TCK compliant. Official Java Docker image is based on OpenJDK.Azul Systems provide commercial support for OpenJDK. Another option is to use OpenJDK images available from Azul systems. These are fully tested and compatibility verified builds of the latest versions of the OpenJDK 8, 7, and 6 platforms.

    Oracle publishes Dockerfile for JDK but don’t publish the images. Note that this definition uses oraclelinux:latest as the base image and you may want to use ubuntu, centos or alpine. In this case, you can create your own Dockerfile.

    Running Java on Docker? You’re breaking the law provides a good summary of why Oracle JDK-based image should not be pushed to Docker Hub.

  • How do you have a container with WildFly use a container with the db on another server?

    Docker Links are legacy and only allow containers to talk to each on the same host. The recommended way for two containers to communicate is using Docker Networks.By default, Docker Swarm cluster creates an overlay network that allows multiple containers to talk across hosts. Multi-container and multi-host applications using WildFly and Couchbase shows how to connect WildFly with Couchbase where each container is running on two separate hosts on a Docker Swarm cluster.Here is the Compose file for reference:

Here are some more references:

  • Learn all about IntelliJ and Docker at jetbrains.com/idea/docker/
  • Self-paced Docker for Java Developers workshop
  • Docker for Java developers Introductory slides
  • Script for Docker and IntelliJ demo shown in the video
  • Docker Docs
  • Couchbase on Containers

Source: http://blog.couchbase.com/2016/may/docker-java-intellij-idea-webinar-replay

WildFly 9 on NetBeans, Eclipse, IntelliJ, OpenShift, and Maven (Tech Tip #86)

wildfly9-banner

WildFly 9 CR1 was recently released. Lots of cool features are included:

  • Intelligent load balancing
  • HTTP/2 and SPDY support
  • A new offline CLI mode
  • Graceful single node shutdown
  • A new Servlet-only distribution

And this is above the usual Java EE 7 compliance!

This blog is a quick check to verify that it works in all three major IDEs and OpenShift.

WildFly 9 and NetBeans

Lets start with NetBeans 8.0.x first. The screenshot shows WildFly 9 CR1 configured in NetBeans and started. The log is shown in the console.

WildFly 9 CR1 on NetBeans

Complete instructions to setup WildFly in NetBeans are in NetBeans 8 and WildFly 8.

WildFly 9 and Eclipse

Getting Started with JBoss Tools and WildFly 8 shows how to configure WildFly with JBoss Tools. Here are the series of snapshots that shows configuring WildFly 9 in JBoss Tools with Eclipse Mars M6.

A new experimental runtime …

WildFly 9 CR1 Experimental

Specify the directory …

WildFly 9 CR1 Eclipse New Runtime

Now WildFly 9 is configured as a Server in Eclipse …

WildFly 9 CR1 Eclipse Servers

And finally the server is up and running …

WildFly 9 CR1 Eclipse Console

Complete details, including download and update center coordinates, are explained at JBoss Tools Alpha 2 for Eclipse Mars.

WildFly 9 and IntelliJ

WildFly 8 and IntelliJ IDEA Screencast provide complete details on how to setup IntelliJ with WildFly. The snapshot below shows WildFly 9 configured in IntelliJ 14.1.2.

WildFly 9 CR1 with IntelliJ 14

WildFly 9 and OpenShift

Creating an OpenShift application is pretty straightforward as well:

This creates a new application and uses WildFly 9 as the underlying application server. Complete details about the OpenShift cartridge are at github.com/openshift-cartridges/openshift-wildfly-cartridge/tree/wildfly-9. You can find about how to create an OpenShift application with an existing application, how to connect to this WildFly instance using JBoss CLI.

WildFly 8 CR1 on OpenShift also provide more details.

WildFly 9 and Maven

WildFly Maven Plugin  provide the latest information about how to get started with WildFly Maven plugin.

But you just need to fire up a WildFly server as:

And then deploy the Java EE 7 Movieplex application as:

And the plugin definition is very simple:

Enjoy!

WildFly 8 and IntelliJ IDEA Screencast (Tech Tip #19)

Viktor Gamov (@gAmUssA) published a screencast that shows how to do Java EE 7 development with WildFly and IntelliJ IDEA. The video shows how to:

  • Download and install (basically unzip 😉 WildFly
  • Configure JBoss plugin in IDEA (this enables support for WildFly)
  • Configure WildFly in IDEA
  • Run a Java EE 7 sample on WildFly

Nicely done, enjoy!

Don’t forget a ton of Java EE 7 samples are available at github.com/javaee-samples/javaee7-samples.

Getting Started with IntelliJ IDEA by PacktPub Book Review


Language : English
Paperback : 114 pages [ 235mm x 191mm ] Release Date : October 2013
ISBN : 1849699615
ISBN 13 : 9781849699617
Author(s) : Hudson Orsine Assumpção

The book shows IntelliJ IDEA 12 features and capabilities for web and desktop development. It also provide general tips to help improve development speed. Readers would need MySQL 5.5, Apache Tomcat 7, and JDK 7 for building applications.

Here is the Table of Contents:

Chapter 1: Getting Started with IntelliJ IDEA 12
Chapter 2: Improving Your Development Speed
Chapter 3: Working with Databases
Chapter 4: Web Development
Chapter 5: Desktop Development

It starts with basic navigation of source code and covers smart code completion, code analysis, advanced refactoring, navigation and search, live templates, and many other features that boosts your productivity. It also shows how to organize the activities necessary to do work such as task and context management and TODO marking.

A complete application development experience require a database and web and desktop application development. The book explains how IntelliJ work with databases, such as generating tables, managing the data, and even creating ORM entities for JPA or Hibernate. The web application created in the book uses JavaServer Faces with Primefaces toolkit, Spring, and SOAP web services and deploys on Tomcat 7. In agile methodology and TDD spirit this chapter also shows how to create and run tests using JUnit. Desktop application is covered using AWT and SWT.

Even though IntelliJ IDEA 13 is already out, this book gives a good introduction for beginners. It may provide some tips for expert users as well.

You can purchase the book from here and send feedback to feedback@packtpub.com.

IntelliJ IDEA 13, Java EE 7 and WildFly (Tech Tip #4)

IntelliJ IDEA 13 was recently released – download now!

intellij-idea13

What’s New provide a comprehensive list of new features in this release, and there are plenty! Needless to say the features that I’m most excited about is Java EE 7 and WildFly support.

Here are some of the highlights for Java EE 7 in IDEA 13:

  • Support for JavaServer Faces 2.2 including a rich set of coding assistance features for flows, actions, contracts, pass-through attributes, and more.
  • Improved navigation, code analysis, and diagrams for injected beans, including Context and Dependency Injection 1.1 annotations and beans.xml configuration.
  • New JAX-RS 2.0 and WebSocket annotations are supported with additional code completion and analysis for path parameters; improved REST Client tool window (now with authorization capabilities and requests history.)
  • Advanced coding assistance for Batch Processing jobs definition, including specific code completion, navigation, code analysis, and many more.
  • Easier project configuration: no need to download or configure Java EE libraries if they are bundled with application server you’re using. This was my personal pet peeve for the longest time and is very clean now.

Andrey Cheptsov (from JetBrains), Antonio Goncalves (a very famous Java person 😉 and myself did a webinar a few days ago highlighting some of these capabilities. A replay of the webinar is now available:

Here is a quick tutorial and a playlist of videos that show the Java EE 7 features in detail:

WildFly 8 Beta2 snapshot can be easily configured as well:

techtip4-wildfly8-beta2-snapshot-idea13

Here are some additional videos for you to get started:

  • How to import Java EE 7 samples from GitHub,
  • How to test RESTful web applications using REST Client tool window,
  • How to debug WebSockets,
  • And finally how to configure Java EE 7 using Gradle.

A fully imported Java EE 7 samples repo is shown below:

tectip4-javaee7-samples

IntelliJ has definitely matured a LOT since I tried it first a few years ago. Congratulations to the entire team for a release well done, especially Andrey who really listened to all the feedback and Philip Torchinsky (ex-colleague and a friend) who triggered my interest back in IntelliJ.

Note that Java EE support is only available in Ultimate Edition, not the free Community Edition. Compare the feature sets between the two here. Both the bundles are available for download here.

Also note, IDEA 13 still requires JDK 6 for retina display although there is a hack available for JDK 7.