I know how to create a jar from .java or .class files.
I have a sources.jar
that contains .java
files. I want to compile these classes and pack into a jar
again.
for example: This is the jar I want to compile:
hadoop-mapreduce-examples-2.2.0-test-sources.jar
.
I did jar xvf hadoop-mapreduce-examples-2.2.0-test-sources.jar
to extract everything.
I now have
ls
META-INF org
ls org/apache/hadoop/
examples mapreduce
ls org/apache/hadoop/examples/
TestBaileyBorweinPlouffe.java TestWordStats.java pi terasort
As you can notice, I have two packages within org.apache.hadoop
, "examples and mapreduce", both of which have to be compiled. And I have sub-packages within "examples" that needs to be compiled.
javac org/apache/hadoop/mapreduce/lib/db/TestDBJob.java
This compiled fine
But How can I compile recursively. I tried using wildcard '*'.
This is what I tried:
javac -cp org/apache/hadoop/examples/*
javac: invalid flag: org/apache/hadoop/examples/pi
Usage: javac <options> <source files>
use -help for a list of possible options
javac org/apache/hadoop/examples/*.*
In the last javac
executed above, I don't see the subpackages being compiled. only the top-level java files was compiled.
Is there a simple solution such as
javac -jar <input.jar> <output.jar>
will result in <output-jar>
that has compiled files in it.
EDIT:
To re-iterate my question:
given a jar that has only .java
files, I want a jar file that has .class
files in the simplest possible way