A new release of Cloud Foundry Integration for Eclipse is available which features the ability to publish standalone Java applications to CloudFoundry.com using either Java 6 or Java 7. Java 7 is also now supported for Grails, Java Web and Spring applications. Standalone applications can only be published to Cloud Foundry instances that support standalone applications such as CloudFoundry.com.
The new integration (version 1.2.0) allows users to publish standalone Java applications from within Eclipse Indigo JEE or SpringSource Tool Suite (STS) version 2.9.0 or higher.
The previous Cloud Foundry plugin (1.1.0) introduced tunneling support for data services, and further improvements to service tunneling are also available as part of 1.2.0.
Follow the documented instructions to install the Cloud Foundry Integration for Eclipse. If you had previously installed Cloud Foundry plugin 1.0.0 or 1.1.0 in Eclipse or STS, the update will be automatically detected or you can manually check for updates in the IDE. Note that updates for older Cloud Foundry plugins prior to 1.0.0 are not supported. Old versions prior to 1.0.0 must first be uninstalled before installing 1.2.0.
Enabling Standalone Support
Java projects in Eclipse can now be published to CloudFoundry.com by enabling Cloud Foundry standalone support on the Java project, and then dragging and dropping them like any other supported application type (Grails, Spring) into either a Cloud Foundry server instance in the Servers view or into the Applications section in the server editor.
To make your Java project publishable to CloudFoundry.com, simply select it in either the Project or Package Explorer, right-click and choose Configure -> Enable as Cloud Foundry Standalone App.
To remove the configuration, select Configure -> Disable as Cloud Foundry Standalone App.
A Java standalone application can be published in just a few simple steps:
- Right-click on the Java project and enable standalone support.
- Drag and drop the application into either the Servers view or server editor for a CloudFoundry.com server.
- Complete the Application wizard that opens, much like publishing any other supported application type.
Configuring a Standalone Java Application
Once a standalone Java application is dragged and dropped into either a CloudFoundry.com server instance in the Servers view, or the server’s editor, an Application wizard is opened allowing a user to configure the application details like the application name and runtime type.
Both Java 6 and Java 7 are supported for standalone applications and a user can select either one from the “Runtime” widget shown above.
In many cases, the standalone support will automatically detect a Java type with a main method, and the application can be deployed from the first page of the wizard. If no main method type was detected, or if a user wants to change the automatically resolved type, clicking “Next” will display a page where the Java start command can be set.
Unlike other supported applications like Grails or Spring, URLs are optional for standalone Java applications. However, a start command is required.
A user has the option of specifying the start command in one of two ways:
- Java: A JVM Java start command with recommended default options set to “$JAVA_OPTS -cp lib/*:.” and a Java type with a main method. The lib folder for the class path option need not exist in the Java project. It is automatically created remotely in the Cloud Foundry server and it is where all jar project dependencies, excluding the JRE dependency, are published.
- Other: A full user-defined start command, which may include the name of a script file.
For the first option, a user can use the built in Java content assist in the Main Type text widget to select a Java type.
Alternately, the Browse button can be clicked to open a Java type browse dialogue.
If selecting Other, the full start command can be specified, like a script file as seen below.
Once published, the standalone application can be managed from the Cloud Foundry server editor like other application type, including starting, stopping, restarting and update restarting, and removing the application, as well as changing the number of application instances and memory settings. In addition, the published resources can be browsed by clicking on Remote Systems View in the server editor.
Java Application Dependencies
All standalone dependencies, with the exception of the JRE dependency, are automatically resolved and published to a remote “lib” folder relatively to the application folder in the Cloud Foundry server. The lib folder need not exist in the Java application before publishing it.
For example, for a Java Maven project, all Maven dependencies are published to the remote lib directory relative to the application.
The Cloud Foundry standalone support determines what application resources to publish to the cloud server based on the configuration defined in the project’s Java Build Path. Any resources that the application requires, including Java source output or target folders, binaries, and XML and script files, need to be listed in the project’s Java Build Path. The Java Build Path can be accessed by right-clicking on the Java project and selecting Build Path -> Configure Build Path…
In addition, the standalone support automatically skips any test source folders, even when listed in the project’s Java Build Path. Output targets for sources folders containing the pattern “src/test” are skipped.
Java 7 Support for Other Application Types
In addition to supporting Java 7 for standalone applications, Cloud Foundry Integration for Eclipse and STS now supports Java 7 for Grails, Spring, Java Web and Lift for CloudFoundry.com. For other cloud servers, Java 6 is still the default runtime type. Java 7 is only shown if the server supports it.
Cloud Foundry Integration for Eclipse 1.2.0 can be installed or updated from the official update site:
http://dist.springsource.com/release/TOOLS/cloudfoundry/
- The Cloud Foundry Team
Don’t have a Cloud Foundry account yet? Signup for free today
About the Author