I have multiple .java files for my hadoop project. How do I execute them without using eclipse?
PS: I use the default ubuntu terminal
I have multiple .java files for my hadoop project. How do I execute them without using eclipse?
PS: I use the default ubuntu terminal
You can use javac *.java to compile all the files in the current working directory. As for executing them, use java filename
Where the filename does NOT have the .class at the end. IE, you have MyProgram.java
which compiles into MyProgram.class
you would type: java MyProgram
You want the run the main class of your project btw (slightly vague, but it might be the only one with a main method).
Following is the simple steps for compiling hadoop java files and executing programs:
Compile:
javac -classpath < HADOOP_INSTALL_DIR>/hadoop-< Version>.jar -d < OUTPUT_DIR_NAME> ( < YOUR_MUTLIPLE_JAVAFILES_PATH> --like *.java)
Build jar file:
jar cvf < YOUR_JAR_FILE_PATH_WITH_NAME> -C <(previous compiled output)OUTPUT_DIR_NAME>
Run Hadoop program using Hadoop Jar command:
hadoop jar < JAR_FILE_PATH> < MAIN_PROGRAM_NAME_IN_JAR> < INPUT_PARAMETERS_IF-ANY>
Hope this helps!