Development Tools

Java on Windows User Guide

| Product: Java on Windows

Overview

This guide covers the deployment and use of Java on Windows Server using cloudimg AMIs from the AWS Marketplace. This AMI provides a preconfigured Windows environment with Java preinstalled, ready for developing and running Java applications.

What's included in this AMI:

  • Java (JDK) preinstalled and configured in the system PATH
  • Command Prompt desktop shortcut for quick access
  • Windows Server with Remote Desktop access
  • 24/7 cloudimg support with guaranteed 24 hour response SLA

Prerequisites

Before launching this AMI, ensure you have:

  1. An active AWS account
  2. An active subscription to the Java on Windows listing on AWS Marketplace
  3. An EC2 key pair for password decryption
  4. A Remote Desktop client application

Recommended Instance Type: t3.medium (2 vCPU, 4 GB RAM) or larger. The minimum requirements are 1 vCPU, 1 GB RAM, and 30 GB disk space.

Step 1: Launch the AMI

  1. Navigate to the AWS Marketplace and search for "Java Windows cloudimg"
  2. Click Continue to Subscribe, accept the terms, then Continue to Configuration
  3. Select your preferred Region and Software Version
  4. Click Continue to Launch
  5. Choose Launch through EC2 for full control over instance configuration
  6. Select your instance type (t3.medium recommended)
  7. Configure storage: 30 GB gp3 minimum
  8. Configure your Security Group with the following inbound rules:
Port Protocol Source Purpose
3389 TCP Your IP Remote Desktop (RDP) access
  1. Select your EC2 key pair and launch the instance

Step 2: Retrieve the Windows Password

Wait for the EC2 instance to pass 2/2 status checks.

  1. Open the AWS Console and navigate to EC2 > Instances
  2. Select your instance
  3. Click Actions > Security > Get Windows password
  4. Click Browse and upload your EC2 key pair .pem file
  5. Click Decrypt password
  6. Note the Username (Administrator) and the decrypted Password

Important: It may take up to 15 minutes after launch before the Windows password is available.

Step 3: Connect via Remote Desktop

Open your Remote Desktop client:

On Windows: 1. Press Win + R, type mstsc, and press Enter 2. Enter the public IP address of your instance 3. Click Connect

On macOS: 1. Open Microsoft Remote Desktop 2. Click Add PC and enter the public IP address 3. Double click the connection to connect

When prompted: - Username: Administrator - Password: The decrypted value from Step 2

If a certificate warning appears, click Continue to proceed.

Step 4: Verify Java Installation

Once connected to the Windows desktop, open Command Prompt using the desktop shortcut or by pressing Win + R, typing cmd, and pressing Enter.

Verify Java is installed and accessible:

java --help

This will display the Java usage information including available options and commands. You can also check the specific version:

java -version

Using Java

Compile and run a Java program:

  1. Create a file named HelloWorld.java: cmd notepad HelloWorld.java

  2. Enter the following code: java public class HelloWorld { public static void main(String[] args) { System.out.println("Hello from cloudimg on AWS!"); } }

  3. Compile the program: cmd javac HelloWorld.java

  4. Run the program: cmd java HelloWorld

Run a JAR file:

java -jar your-application.jar

Check JAVA_HOME environment variable:

echo %JAVA_HOME%

Server Components

Component Version
Java (JDK) Latest

Filesystem Layout

Drive Description
C:\ System drive with Windows and Java installation

Key directories:

Directory Purpose
C:\Program Files\Java Java JDK installation
C:\Users\Administrator User home directory
C:\Users\Administrator\Documents Default working directory

Troubleshooting

Java command not found

  1. Open Command Prompt and type java -version
  2. Verify JAVA_HOME is set: echo %JAVA_HOME%
  3. Check the PATH variable includes the Java bin directory: echo %PATH%
  4. If Java is not in PATH, add it manually: cmd set PATH=%PATH%;C:\Program Files\Java\jdk-<version>\bin

Cannot connect via RDP

  1. Verify the instance has passed 2/2 status checks
  2. Check that your security group allows port 3389 from your IP
  3. Wait up to 15 minutes for the Windows password to be available

Out of memory errors when running Java applications

  1. Increase the JVM heap size: java -Xmx4g -jar your-application.jar
  2. Consider upgrading to a larger EC2 instance type
  3. Monitor memory usage in Task Manager

Security Recommendations

  • Change the Administrator password after first login
  • Restrict RDP access: Only allow port 3389 from your specific IP address
  • Enable Windows Update: Keep the OS patched with the latest security updates
  • Keep Java updated: Regularly check for and apply Java security updates
  • Use strong passwords: Set a complex password for the Administrator account
  • Consider a VPN: For regular access, connect through a VPN rather than exposing RDP directly

Support

If you encounter any issues with this product, contact cloudimg support:

  • Email: support@cloudimg.co.uk
  • Website: www.cloudimg.co.uk
  • Support hours: 24/7 with guaranteed 24 hour response SLA