I have a Rascal project I would like to export to a JAR file to be ran like a terminal application, so users can simply run the JAR from command line instead of running it from Eclipse. Is there a way to do this? I tried to export it like a regular Java project but I'm not sure how to specify things such as the JAR's entry point.
2 Answers
Here is an updated answer for the current Rascal 0.18.2, in a more cookbook-like fashion. @davy-landman helped me to put this together.
Presume you have a very simple Rascal module that you want to deploy to the command line, like this HelloWorldMain.rsc
:
module HelloWorldMain
import IO;
int main(int arg=1) {
println("Hello, World!");
return 0;
}
Put it in a HelloWorldMain.jar
file with the following structure:
|- src
|- HelloWorldMain.rsc
|- META-INF
|- RASCAL.MF
The contained RASCAL.MF file looks like this:
Manifest-Version: 0.0.1
Project-Name: MyRascalProject
Source: src
Main-Module: HelloWorldMain
Main-Function: main
You can then invoke it with
java -Xmx1G -Xss32m -cp "HelloWorldMain.jar;rascal-0.18.2.jar" org.rascalmpl.shell.RascalShell
assuming both your custom and the Rascal jar are in the current directory. The order of the files in the class path matters. Make sure the Java binary you invoke is from a JDK (not a JRE). This will directly run the main()
method from your HelloWorldMain module.

- 22,276
- 13
- 61
- 62
-
1and you could provide `-arg 32`on the commandline to override the default `int arg=1` binding, – Jurgen Vinju Jul 28 '20 at 12:44
It depends a bit on the API's your using.
- If they are eclipse specific (the jdt submodule of m3) or if they are using the eclipse language services, you'll have to create a plug-in and a feature project. This is not for the faint of heart, but it works. I'll try to find an example.
- If you want a terminal like application, you can take the existing unstable/stable jar from the website, and copy your files in there, and update the rascal.mf file to also include your subdirectory in the search path. The shell should work automatically.
- If you want to link rascal functions from Java code, you'll have to do some work to correctly connect the evaluator. (And then do point 1 or 2)
So, if you could make your question more specific, I'll make a specific answer to your case, examples included.
(This answer is a bit of a half comment/half answer, sorry).

- 15,109
- 6
- 49
- 73
-
Hi, thanks for the answer, I updated my question accordingly. My use case is your second option. – urielSilva May 22 '18 at 12:29