Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [SOLVED] Export DSL as runnable Jar(How to export a DSL created with xtext and xtend to a runnable jar)
[SOLVED] Export DSL as runnable Jar [message #1827100] Thu, 07 May 2020 08:21 Go to next message
Luca Reccia is currently offline Luca RecciaFriend
Messages: 14
Registered: May 2020
Junior Member
Hello guys,

I'm tring to export my eclipse dsl plugin as a jar to call it from command line.
It should be pretty straight forward, I followed these steps: http://thomas.trocha.com/pebble/xtext-export-dsl-as-runnable-jar

The problem is whenever I try to execute the program I get:
`
Error: unable to initialize main class ...generato.Main
Caused by: java.lang.NoClassDefFoundError: org/eclipse/xtext/generator/IGeneratorContext
`

I've searched online but didn't found any solution.
Do any of you know how can I solve this problem?

[Updated on: Thu, 07 May 2020 17:37]

Report message to a moderator

Re: Export DSL as runnable Jar [message #1827101 is a reply to message #1827100] Thu, 07 May 2020 08:25 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
are you sure the classpath is sufficient? is the class in the jar?
which option did you select in the dialog


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Export DSL as runnable Jar [message #1827102 is a reply to message #1827101] Thu, 07 May 2020 08:40 Go to previous messageGo to next message
Luca Reccia is currently offline Luca RecciaFriend
Messages: 14
Registered: May 2020
Junior Member
I've posted the export page, that launch configuration works when running from eclipse
Re: Export DSL as runnable Jar [message #1827108 is a reply to message #1827102] Thu, 07 May 2020 09:46 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
but the missing class is not in the jar?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Export DSL as runnable Jar [message #1827111 is a reply to message #1827108] Thu, 07 May 2020 10:36 Go to previous messageGo to next message
Luca Reccia is currently offline Luca RecciaFriend
Messages: 14
Registered: May 2020
Junior Member
(EDIT: I forgot to mention that the missing class should be taken from an external library)

No they are not.
The project has the external jar in the class path if checking in the project properties.
But If i try to export the project as runnable JAR the libraries are not added to the generated JAR


What should I do to add them?

[Updated on: Thu, 07 May 2020 10:39]

Report message to a moderator

Re: Export DSL as runnable Jar [message #1827112 is a reply to message #1827111] Thu, 07 May 2020 11:11 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
if the project that has the main has a proper classpath then if you select that extract into
everything should be there.

thus i wonder on where you main is and how the classpath looks like


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Export DSL as runnable Jar [message #1827121 is a reply to message #1827112] Thu, 07 May 2020 16:10 Go to previous messageGo to next message
Luca Reccia is currently offline Luca RecciaFriend
Messages: 14
Registered: May 2020
Junior Member
Well the main is autogenerated from xtend and is locate inside xtend-gen/<package>/generator/Main.java
Re: Export DSL as runnable Jar [message #1827124 is a reply to message #1827121] Thu, 07 May 2020 16:19 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
(1) create a new project using the wizard
(2) change the workflow to create a main
(3) run workflow
(4) run main once
(5) export
(6) run the jar

works (emf mimimis about The string resource '_UI_DiagnosticRoot_diagnostic' could not be located but thats no problem - https://stackoverflow.com/questions/38043360/error-when-validating-xtext-dsl-in-standalone-java-project)


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Thu, 07 May 2020 16:20]

Report message to a moderator

Re: Export DSL as runnable Jar [message #1827125 is a reply to message #1827124] Thu, 07 May 2020 17:37 Go to previous message
Luca Reccia is currently offline Luca RecciaFriend
Messages: 14
Registered: May 2020
Junior Member
I solved downloading all the org.eclipse.xtext jar dependecies from https://jar-download.com/artifacts/org.eclipse.xtext/org.eclipse.xtext.xtext.generator (it's one single zip) choosing the right version and then launched my jar with:

java -cp "<dowloadedlibfolders>/*:<Path to my jar>/myjar.jar" it.<packege to main>.Main <my args>
Previous Topic:[SOLVED] Porting project from xtext plugin to xtext lsp server
Next Topic:Creating Custom Task Tags
Goto Forum:
  


Current Time: Fri Apr 19 21:12:45 GMT 2024

Powered by FUDForum. Page generated in 0.04170 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top