1

I have been following this tutorial on getting started with Spoon.

I've been having difficulty getting the following command to run (located at the bottom of the page in the link above):

$ java -classpath /path/to/binary/of/your/processor.jar:spoon-core-{{site.spoon_release}}-jar-with-dependencies.jar spoon.Launcher -i /path/to/src/of/your/project -p processors.CatchProcessor

Could someone please break down and explain what is needed in this command, specifically the bit after -classpath.

Ps. Anyway I try to run the command the error I get is:

Class not found Spoon.Launcher

Liam
  • 11
  • 1

2 Answers2

0

Actually everything is needed in this command: it's the smallest command to use a processor. The bit after classpath, tells Java where to find the classes to load: you need to tell it where to find the Spoon jar and the jar containing your processor. Each jar is separated by a colon (:). More information about classpath there: https://en.wikipedia.org/wiki/Classpath_(Java)

The spoon.Launcher part tells to call the class Launcher in package spoon. And the following are arguments of Spoon. You have information about those arguments there: http://spoon.gforge.inria.fr/command_line.html

So first you have to download a version of Spoon jar. You can download the last version there: https://github.com/INRIA/spoon/releases/download/spoon-core-5.9.0/spoon-core-5.9.0-jar-with-dependencies.jar Then you have to create a processor and to compile it. Then you can use Spoon by specifying the path of the downloaded jar and your processor class in classpath as explained above.

Please also note that the last version of the documentation is available there: http://spoon.gforge.inria.fr/first_analysis_processor.html. It will display properly some annotation like the spoon_release number.

Simon Urli
  • 449
  • 1
  • 5
  • 12
  • Hey thanks for your help :). I'm still having a bit of trouble when executing the command. I get this error "Exception in thread "main" spoon.compiler.ModelBuildingException: The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files at " do you have any ideas? – Liam Nov 08 '17 at 17:04
  • Do you use an IDE to launch Spoon? It may be related with the configuration of your JDK. Try launching it directly in command line. – Simon Urli Nov 09 '17 at 09:22
  • I'm launching it from command line, my JAVA_HOME is JDK 1.8.0_144. It's on windows by the way – Liam Nov 09 '17 at 10:41
  • java -cp spoon-examples-1.0-SNAPSHOT.jar;spoon-core-5.9.0-jar-with-dependencies.jar spoon.Launcher -i "C:\Users\Liam Mullen\workspace\Farm\src" -p fr.inria.gforge.spoon.analysis.CatchProcessor – Liam Nov 09 '17 at 12:39
0

I think you should think about the another easier ways (maven-plugin jar) to use spoon.

Yongfeng
  • 345
  • 1
  • 3
  • 15