SBT complètera, mais pas exécuter ce projet très simple. Pourquoi pas?Pourquoi SBT ne détecte-t-il pas la classe principale en Java? (Aucune classe principale détectée)
[email protected]:~/tmp/javahello$ sbt --version
sbt launcher version 0.12.1
[email protected]:~/tmp/javahello$ find .
.
./src
./src/main
./src/main/java
./src/main/java/learn
./src/main/java/learn/HelloWorld.java
[email protected]:~/tmp/javahello$ cat src/main/java/learn/HelloWorld.java
package learn;
class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, world");
}
}
[email protected]:~/tmp/learn/javahello$ sbt run
[info] Set current project to default-1004d5 (in build file:/home/mackler/tmp/javahello/)
[info] Updating {file:/home/mackler/tmp/javahello/}default-1004d5...
[info] Resolving org.scala-lang#scala-library;2.9.2 ...
[info] Done updating.
[info] Compiling 1 Java source to /home/mackler/tmp/javahello/target/scala-2.9.2/classes...
java.lang.RuntimeException: No main class detected.
at scala.sys.package$.error(package.scala:27)
[trace] Stack trace suppressed: run last compile:run for the full output.
[error] (compile:run) No main class detected.
[error] Total time: 4 s, completed Sep 22, 2013 4:14:21 PM
[email protected]:~/tmp/javahello$
Fascinant; Je vous remercie. Je l'ai copié dès la première partie du livre de Gosling. Il fonctionne comme initialement posté en utilisant 'javac' et' java' mais je suppose qu'il devrait mettre à jour le livre pour refléter SBT. –
Si 'java' l'accepte mais que' sbt' ne l'accepte pas, c'est un bug dans sbt. S'il vous plaît ouvrir un problème. –
C'est bizarre. J'ai supposé que ça ne marcherait pas aussi bien en Java, mais c'est le cas. –