This is more about deploying the Nashorn standalone module in the context of Apache Tomcat 10
("jakarta"-namespace) not about creating a stand-alone Java application.
---rony
On 03.10.2022 19:03, Remi Forax wrote:
----------------------------------------------------------------------------------------------------
*From: *"Simon Besenbäck" <[email protected]>
*To: *[email protected]
*Sent: *Monday, October 3, 2022 3:04:26 PM
*Subject: *Using Nashorn in Apache Tomcat
Hi!
I am using Apache 10.0.23 on Windows 10. I want to use Nashorn for
developing JSP's within the
Eclipse IDE. Therefore I use OpenJDK 19 and added the
jakarta.ScriptTagLibs.jar to the lib
directory. I added script-jsr223.tld to the META-INF Folder. As far as I
know I should be able
to use nashorn if I add the nashorn-core-15.4.jar (downloaded here:
https://search.maven.org/artifact/org.openjdk.nashorn/nashorn-core/15.4/jar) to
the lib
directory, but for me it doesn´t work. I either get the Page without the
elements generated by
nashorn or I get an Internal Server Error.
However, I also tried Rhino, by adding rhino-engine-1.7.14.jar and
rhino-runtime-1.7.14.jar to
the lib directory and it works. Though, if I try it by only adding the
rhino-1.7.14.jar to the
lib directory it won't work either. (Downloaded here:
https://github.com/mozilla/rhino/releases/tag/Rhino1_7_14_Release)
I would be very thankful for any tipps as I really do not know how to get
nashorn working.
Usually, when you want to build a Java application with some dependencies, the best is to use a
build tool that will download the dependencies for you *and* configure your IDE for you.
For a small project like the one you describe, i believe it's simpler to use Maven. Maven uses a
pom.xml file that describes the dependencies and some plugins, you have one for tomcat by example.
There is an eclipse plugin called m2eclipse that configure eclipse from the pom.xml (you have to
activate an option in the m2e plugin).
There are a lot of tutorial on the internet on how to use Maven with Eclipse.
Once you have played a little with Maven, dependencies should be a problem from the past and you
should be able to focus on what you want to do :)
Thanks.
Simon
regards,
Rémi