0% found this document useful (0 votes)
104 views5 pages

Steps To Run A JAVA API On Virtual-Box

1. Download a Java file and copy it to a virtual machine running Cloudera QuickStart VM. 2. Move the Java file to a new 'Test' folder and create a 'test_classes' subfolder to store compiled classes. 3. Use commands like 'javac' and 'jar' to compile the Java file, create a JAR file with the classes, and run the JAR file on Hadoop.

Uploaded by

Ram Guggul
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
104 views5 pages

Steps To Run A JAVA API On Virtual-Box

1. Download a Java file and copy it to a virtual machine running Cloudera QuickStart VM. 2. Move the Java file to a new 'Test' folder and create a 'test_classes' subfolder to store compiled classes. 3. Use commands like 'javac' and 'jar' to compile the Java file, create a JAR file with the classes, and run the JAR file on Hadoop.

Uploaded by

Ram Guggul
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

RUNNING A JAVA API on VIRTUAL-BOX

Steps to run a JAVA API on Virtual-Box

1. First, start the Virtual-Box on your machine. It is necessary to have Cloudera QuickStart
VM installed on your linux virtual machine. To do this, follow the steps in this ​video​.
Download the ‘FileSystemOperationsTest.java’​ ​file from​ here​.

2. A copy of the ‘FileSystemOperationsTest.java’​ ​file should be present in the virtual


machine in order to carry out further operations. One simple way is to copy the
contents of the ‘FileSystemOperationsTest.java’ file to the clipboard, create a new file in
the virtual machine with an extension ‘.java’ and paste the contents. If you have a Mac
machine, click on ‘Edit’ followed by ‘Paste’. If you have a windows machine, right click
followed by ‘Paste’.

3. Create a new folder (Say ‘Test’) and move the file created in the first step to this folder.

4. Create another folder inside this folder (Say ‘test_classes’ inside the folder ‘Test’) to
store the Java classes.
5. Now open the terminal and type the following command:
export HADOOP_CLASSPATH=$(hadoop classpath)

6. Use the following command to check if the path has been set correctly:
echo $HADOOP_CLASSPATH

7. Change to the directory where the ‘FileSystemOperationsTest.java’ is stored (‘Test’ in


this case) using the cd command.
8. Compile this Java program and store the classes produced after compilation in the
folder created for storing Java classes (‘test_classes’ in this case). Use the following
commands to do this:
Syntax:
javac -classpath ${HADOOP_CLASSPATH} -d <enter the path of your classes folder>
<enter the path of the ‘FileSystemOperationsTest.java’ file>

Please note that the command shown below is a single command and not three
different commands. The second line in the below command is the path of the classes
folder. Instead of typing the same, you may drag the folder and drop in the terminal.
Similarly, the third line below is the path of the ‘FileSystemOperationsTest.java’ file.
Instead of typing it, you may drag the file and drop it in the terminal.

javac -classpath ${HADOOP_CLASSPATH} -d


‘/home/cloudera/Desktop/Test/test_classes’
‘/home/cloudera/Desktop/Test/FileSystemOperationsTest.java’
9. Put all the output class files in one jar file (say ‘test.jar’). To create the jar file, use the
following command:
Syntax:
jar -cvf <JAR_FILE_NAME> -C <CLASSES_FOLDER> .
jar -cvf test.jar -C test_classes/ .

As you can see the test.jar has been created which is highlighted in this image. Please do
verify the same. If the output is not the same as shown in the terminal, delete the jar file
created and re-run the command to create the jar file. Please be careful with the spaces
in the command.
10. Run this jar file on Hadoop using the following command:
Syntax:
hadoop jar <JAR_FILE> <CLASS_NAME>
hadoop jar test.jar FileSystemOperationsTest

You might also like