This code should work (at least it works in Rascal 0.9.1). There may be something strange with your Rascal and/or Java setup. Do you have a bin folder with a Teste.class in it? You you have any strange projects in your Eclipse (such as an (incompatible) version of the vallang sources)?
– AnyaDec 27 '17 at 14:05

1

(Also, note that once you get it to work, you probably won't see the result of the println and/or you'll find it in the terminal you started Eclipse from). Alternatively, you could have it return a string: public IString testeJava() { return vf.string("it worked"); }
– AnyaDec 27 '17 at 14:10

Yes, I do have a bin folder with Teste.class in it. I'm trying to find any inconsistencies in the setup. I followed rascal-mpl.org/start to get Rascal up and running.
– urielSilvaDec 27 '17 at 14:18

Did you restart the Rascal console after fixing the constructor? It may not have loaded the new version of your class
– AnyaDec 27 '17 at 14:31

Yes, I also reinstalled RCP Eclipse and everything, but it's still not working.
– urielSilvaDec 28 '17 at 11:24

1 Answer
1

Your Java class needs a public constructor that takes an IValueFactory argument, as seen in the other question. E.g.,public ClassName(IValueFactory vf) { this.vf = vf; }

You have added (1), and the Java class has been recompiled, but Rascal didn't reload it – in which case the solution is (for now) to close the Rascal console and re-open it. I'm not sure if Rascal intends to check for class file changes.

You have (1) and Rascal does reload the class, but the class file hasn't been recompiled, which seems to have been the problem in this case.

As jurgenv mentions, your Eclipse project also needs both the Rascal and Java natures, otherwise the Java builder doesn't run. This should be correctly set up from the start, as long as you created it using New → Rascal Project. For reference, the natures part of your Eclipse .project file should look like this:

Perhaps the code is not located in an Eclipse project with the Rascal and Java natures enabled? In this case I'd create a new Rascal project using the wizard and copy the code there.
– Jurgen VinjuDec 29 '17 at 14:53