Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run simple java app on amazon ec2?

I have access to amazon cloud service ec2, linux instance. I created vi first.java file with this content:

class first {
    public static void main(String[] args) {
        System.out.println("abc");
    }
}

I want to compile the file using:

[root@ip-21-24-273-243 ec2-user]# javac first.java 
bash: javac: command not found

Command not found? I do:

[root@ip-21-24-273-243 ec2-user]# java -version
java version "1.6.0_24"
OpenJDK Runtime Environment (IcedTea6 1.11.9) (amazon-57.1.11.9.52.amzn1-x86_64)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)

So java is installed. How can I run a simple app?

[root@ip-21-24-273-243 ec2-user]# yum install java
Loaded plugins: priorities, security, update-motd, upgrade-helper
amzn-main                                                                                                                      | 2.1 kB     00:00     
amzn-updates                                                                                                                   | 2.3 kB     00:00     
Setting up Install Process
Package 1:java-1.6.0-openjdk-1.6.0.0-57.1.11.9.52.amzn1.x86_64 already installed and latest version
Nothing to do
like image 791
Sophie Sperner Avatar asked Apr 10 '13 18:04

Sophie Sperner


People also ask

How do I create a Java project in AWS?

Click the AWS icon on the Eclipse toolbar, and then click New AWS Java Project. In the dialog box that appears, type a name for the project in the Project name box and select Amazon Simple Queue Service Sample. Click Finish.

How do you Deploy a Java application?

To deploy your Java Web Start application, first compile the source code, package it as a JAR file, and sign the JAR file. Java Web Start applications are launched by using the Java Network Launch Protocol (JNLP). Hence, you must create a JNLP file to deploy your application.

How do I install Java on AWS EC2 Windows?

Step 1: Create an AWS Elastic Cloud Compute Instance. Step 2: Start the EC2 instance that you have created in Step 1. Step 3: Connect to your EC2 Instance by clicking on Connect Button. Step 4: A prompt will pop up after connecting.


1 Answers

You need to install java-1.6.0-openjdk-devel:

yum install java-devel
like image 139
David Levesque Avatar answered Sep 22 '22 07:09

David Levesque