Use java_binary output rather than libs for $(exe).

Summary:
Currently when using $(exe) to reference a java binary in a genrule,
we build the java binary jar and then ignore it.  Instead, we pass a
classpath that loads executable code from the java binary's transitive
dependencies.
diff --git a/src/com/facebook/buck/java/JavaBinaryRule.java b/src/com/facebook/buck/java/JavaBinaryRule.java
index 666802c..a0368b2 100644
--- a/src/com/facebook/buck/java/JavaBinaryRule.java
+++ b/src/com/facebook/buck/java/JavaBinaryRule.java
@@ -39,13 +39,11 @@
 import com.facebook.buck.util.DefaultDirectoryTraverser;
 import com.facebook.buck.util.DirectoryTraverser;
 import com.facebook.buck.util.ProjectFilesystem;
-import com.google.common.base.Joiner;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.ImmutableSetMultimap;
 import com.google.common.collect.ImmutableSortedSet;
-import com.google.common.collect.Iterables;
 
 import java.io.IOException;
 import java.util.List;
@@ -184,11 +182,8 @@
         "Must specify a main class for %s in order to to run it.",
         getBuildTarget().getFullyQualifiedName());
 
-    return String.format("java -classpath %s %s",
-        Joiner.on(':').join(Iterables.transform(
-            getTransitiveClasspathEntries().values(),
-            projectFilesystem.getPathRelativizer())),
-        mainClass);
+    return String.format("java -jar %s",
+        projectFilesystem.getPathRelativizer().apply(getOutputFile()));
   }
 
   public static class Builder extends AbstractBuildRuleBuilder<JavaBinaryRule> {
diff --git a/test/com/facebook/buck/java/JavaBinaryRuleTest.java b/test/com/facebook/buck/java/JavaBinaryRuleTest.java
index 196c5e4..a0ddd8a 100644
--- a/test/com/facebook/buck/java/JavaBinaryRuleTest.java
+++ b/test/com/facebook/buck/java/JavaBinaryRuleTest.java
@@ -60,7 +60,7 @@
         .addVisibilityPattern(BuildTargetPattern.MATCH_ALL));
 
     // java_library //java/com/facebook/base:base
-    JavaLibraryRule javaLibraryRule = ruleResolver.buildAndAddToIndex(
+    ruleResolver.buildAndAddToIndex(
         DefaultJavaLibraryRule.newJavaLibraryRuleBuilder(new FakeAbstractBuildRuleBuilderParams())
         .setBuildTarget(BuildTargetFactory.newInstance("//java/com/facebook/base:base"))
         .addSrc("java/com/facebook/base/Base.java")
@@ -79,10 +79,9 @@
     // Each classpath entry is specified via its absolute path so that the executable command can be
     // run from a /tmp directory, if necessary.
     String expectedClasspath =
-        basePath + PATH_TO_GUAVA_JAR + ":" +
-        basePath + javaLibraryRule.getPathToOutputFile();
+        basePath + javaBinaryRule.getPathToOutputFile();
 
-    String expectedCommand = String.format("java -classpath %s com.facebook.base.Main",
+    String expectedCommand = String.format("java -jar %s",
         expectedClasspath);
     ProjectFilesystem projectFilesystem = createMock(ProjectFilesystem.class);
     Function<String, Path> pathRelativizer = new Function<String, Path>() {
diff --git a/test/com/facebook/buck/shell/GenruleTest.java b/test/com/facebook/buck/shell/GenruleTest.java
index 9228d55..9669807 100644
--- a/test/com/facebook/buck/shell/GenruleTest.java
+++ b/test/com/facebook/buck/shell/GenruleTest.java
@@ -332,10 +332,10 @@
 
     // Verify that the correct cmd was created.
     Path expectedClasspath = getAbsolutePathInBase(
-        GEN_DIR + "/java/com/facebook/util/lib__util__output/util.jar");
+        GEN_DIR + "/java/com/facebook/util/ManifestGenerator.jar");
 
     String expectedCmd = String.format(
-        "java -classpath %s com.facebook.util.ManifestGenerator $OUT",
+        "java -jar %s $OUT",
         expectedClasspath);
     assertEquals(expectedCmd, transformedString);
   }
@@ -357,9 +357,9 @@
 
     // Verify that the correct cmd was created.
     Path expectedClasspath = getAbsolutePathInBase(
-        GEN_DIR + "/java/com/facebook/util/lib__util__output/util.jar");
+        GEN_DIR + "/java/com/facebook/util/ManifestGenerator.jar");
     String expectedCmd = String.format(
-        "java -classpath %s com.facebook.util.ManifestGenerator $OUT",
+        "java -jar %s $OUT",
         expectedClasspath);
     assertEquals(expectedCmd, transformedString);
   }
@@ -412,9 +412,9 @@
 
     // Verify that the correct cmd was created.
     Path expectedClasspath = getAbsolutePathInBase(
-        GEN_DIR + "/java/com/facebook/util/lib__util__output/util.jar");
+        GEN_DIR + "/java/com/facebook/util/ManifestGenerator.jar");
     String expectedCmd = String.format(
-        "java -classpath %s com.facebook.util.ManifestGenerator $OUT",
+        "java -jar %s $OUT",
         expectedClasspath);
     assertEquals(expectedCmd, transformedString);
   }