Discussion:
[jetty-users] Executable jar file for embedded jetty application
west suhanic
2018-03-06 14:53:59 UTC
Permalink
Hello All:

I have a fully functioning embedded jetty application.
I would now like to package it in an executable jar file.
I do not use maven or ant. It is built using a makefile.
I have a manifest file containing the needed jar files etc.
I can build the executable jar file. However the problem occurs
when I run it. The application starts and I get no error messages
but I cannot contact the embedded server via the command line or
a web browser.

I have gone over the documentation and it is not obvious if what I want to
do
is even possible. So I have a few questions:

0)Am I missing something in the documentation?
1)Is building an executable jar file without maven or ant possible?
2)If so, how? Do I need to add some code to my embedded server?

thank you,

west suhanic
Joakim Erdfelt
2018-03-06 17:28:15 UTC
Permalink
Using makefile you'll have a lot of extra work to do with merging various
files for this executable jar (aka uber-jar).

There are 2 example projects we maintain, but they use maven and the
various plugins that do the merging for us in a smart fashion.

If you are working with ServletContextHandler, you can use a uber-jar.

https://github.com/jetty-project/embedded-jetty-uber-jar

This will merge everything that you use into a single executable jar for
yourself.

If you are working with WebAppContext, you can use a live-war.

https://github.com/jetty-project/embedded-jetty-live-war

This produces a war file that, can itself, be executed (like an executable
jar).
This has the same merging concerns as above, but is structured differently
to allow the war file to operate safely.
Post by west suhanic
I have a fully functioning embedded jetty application.
I would now like to package it in an executable jar file.
I do not use maven or ant. It is built using a makefile.
I have a manifest file containing the needed jar files etc.
I can build the executable jar file. However the problem occurs
when I run it. The application starts and I get no error messages
but I cannot contact the embedded server via the command line or
a web browser.
I have gone over the documentation and it is not obvious if what I want to
do
0)Am I missing something in the documentation?
1)Is building an executable jar file without maven or ant possible?
2)If so, how? Do I need to add some code to my embedded server?
thank you,
west suhanic
_______________________________________________
jetty-users mailing list
To change your delivery options, retrieve your password, or unsubscribe
from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users
west suhanic
2018-03-07 17:11:04 UTC
Permalink
Hello All:

I am able to build an uber jar called x.jar via a makefile. The steps are:

1)Build a manifest file with the necessary classpaths specified. Here is
one I auto generate. I have simply
shortened it for this example. The key bit is to have one space after the
colon which terminates "Class-Path" and two
spaces at the start of each classpath line. In the line "Main-Class:
g.m.TheMain" there are two spaces between the
colon and the letter g . Here is the manifest file, called
manifest.mf, which I use on a gentoo machine:

Class-Path:
/home/b/jars/jetty/9.4.8.v20171121/jetty-continuation-9.4.8.v20171121.jar
/home/b/jars/jetty/9.4.8.v20171121/jetty-server-9.4.8.v20171121.jar
/home/b/jars/jetty/9.4.8.v20171121/jetty-http-9.4.8.v20171121.jar
Main-Class: g.m.TheMain

I auto generate this manifest file in the Makefile because my classpath has
over twenty elements.

The jar file statement for the executable jar is:

jar cvfm x.jar ./manifest.mf -C g/m .

Then to use the executable jar do:

java -jar x.jar

thanks,

west suhanic
Post by Joakim Erdfelt
Using makefile you'll have a lot of extra work to do with merging various
files for this executable jar (aka uber-jar).
There are 2 example projects we maintain, but they use maven and the
various plugins that do the merging for us in a smart fashion.
If you are working with ServletContextHandler, you can use a uber-jar.
https://github.com/jetty-project/embedded-jetty-uber-jar
This will merge everything that you use into a single executable jar for
yourself.
If you are working with WebAppContext, you can use a live-war.
https://github.com/jetty-project/embedded-jetty-live-war
This produces a war file that, can itself, be executed (like an executable
jar).
This has the same merging concerns as above, but is structured differently
to allow the war file to operate safely.
Post by west suhanic
I have a fully functioning embedded jetty application.
I would now like to package it in an executable jar file.
I do not use maven or ant. It is built using a makefile.
I have a manifest file containing the needed jar files etc.
I can build the executable jar file. However the problem occurs
when I run it. The application starts and I get no error messages
but I cannot contact the embedded server via the command line or
a web browser.
I have gone over the documentation and it is not obvious if what I want
to do
0)Am I missing something in the documentation?
1)Is building an executable jar file without maven or ant possible?
2)If so, how? Do I need to add some code to my embedded server?
thank you,
west suhanic
_______________________________________________
jetty-users mailing list
To change your delivery options, retrieve your password, or unsubscribe
from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users
Joakim Erdfelt
2018-03-07 17:14:23 UTC
Permalink
Don't forget to merge the META-INF/services/ files too.
Post by west suhanic
1)Build a manifest file with the necessary classpaths specified. Here is
one I auto generate. I have simply
shortened it for this example. The key bit is to have one space after the
colon which terminates "Class-Path" and two
g.m.TheMain" there are two spaces between the
colon and the letter g . Here is the manifest file, called
/home/b/jars/jetty/9.4.8.v20171121/jetty-continuation-
9.4.8.v20171121.jar
/home/b/jars/jetty/9.4.8.v20171121/jetty-server-9.4.8.v20171121.jar
/home/b/jars/jetty/9.4.8.v20171121/jetty-http-9.4.8.v20171121.jar
Main-Class: g.m.TheMain
I auto generate this manifest file in the Makefile because my classpath
has over twenty elements.
jar cvfm x.jar ./manifest.mf -C g/m .
java -jar x.jar
thanks,
west suhanic
Post by Joakim Erdfelt
Using makefile you'll have a lot of extra work to do with merging various
files for this executable jar (aka uber-jar).
There are 2 example projects we maintain, but they use maven and the
various plugins that do the merging for us in a smart fashion.
If you are working with ServletContextHandler, you can use a uber-jar.
https://github.com/jetty-project/embedded-jetty-uber-jar
This will merge everything that you use into a single executable jar for
yourself.
If you are working with WebAppContext, you can use a live-war.
https://github.com/jetty-project/embedded-jetty-live-war
This produces a war file that, can itself, be executed (like an
executable jar).
This has the same merging concerns as above, but is structured
differently to allow the war file to operate safely.
Post by west suhanic
I have a fully functioning embedded jetty application.
I would now like to package it in an executable jar file.
I do not use maven or ant. It is built using a makefile.
I have a manifest file containing the needed jar files etc.
I can build the executable jar file. However the problem occurs
when I run it. The application starts and I get no error messages
but I cannot contact the embedded server via the command line or
a web browser.
I have gone over the documentation and it is not obvious if what I want
to do
0)Am I missing something in the documentation?
1)Is building an executable jar file without maven or ant possible?
2)If so, how? Do I need to add some code to my embedded server?
thank you,
west suhanic
_______________________________________________
jetty-users mailing list
To change your delivery options, retrieve your password, or unsubscribe
from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users
Joakim Erdfelt
2018-03-07 17:16:02 UTC
Permalink
Also, if you have a META-INF/MANIFEST.MF with a `Class-Path` entry, you
don't have a uber jar :-)

You have an old school executable jar with hardcoded classpath.
Post by Joakim Erdfelt
Don't forget to merge the META-INF/services/ files too.
Post by west suhanic
1)Build a manifest file with the necessary classpaths specified. Here is
one I auto generate. I have simply
shortened it for this example. The key bit is to have one space after
the colon which terminates "Class-Path" and two
g.m.TheMain" there are two spaces between the
colon and the letter g . Here is the manifest file, called
/home/b/jars/jetty/9.4.8.v20171121/jetty-continuation-9.4.8.
v20171121.jar
/home/b/jars/jetty/9.4.8.v20171121/jetty-server-9.4.8.v20171121.jar
/home/b/jars/jetty/9.4.8.v20171121/jetty-http-9.4.8.v20171121.jar
Main-Class: g.m.TheMain
I auto generate this manifest file in the Makefile because my classpath
has over twenty elements.
jar cvfm x.jar ./manifest.mf -C g/m .
java -jar x.jar
thanks,
west suhanic
Post by Joakim Erdfelt
Using makefile you'll have a lot of extra work to do with merging
various files for this executable jar (aka uber-jar).
There are 2 example projects we maintain, but they use maven and the
various plugins that do the merging for us in a smart fashion.
If you are working with ServletContextHandler, you can use a uber-jar.
https://github.com/jetty-project/embedded-jetty-uber-jar
This will merge everything that you use into a single executable jar for
yourself.
If you are working with WebAppContext, you can use a live-war.
https://github.com/jetty-project/embedded-jetty-live-war
This produces a war file that, can itself, be executed (like an
executable jar).
This has the same merging concerns as above, but is structured
differently to allow the war file to operate safely.
Post by west suhanic
I have a fully functioning embedded jetty application.
I would now like to package it in an executable jar file.
I do not use maven or ant. It is built using a makefile.
I have a manifest file containing the needed jar files etc.
I can build the executable jar file. However the problem occurs
when I run it. The application starts and I get no error messages
but I cannot contact the embedded server via the command line or
a web browser.
I have gone over the documentation and it is not obvious if what I want
to do
0)Am I missing something in the documentation?
1)Is building an executable jar file without maven or ant possible?
2)If so, how? Do I need to add some code to my embedded server?
thank you,
west suhanic
_______________________________________________
jetty-users mailing list
To change your delivery options, retrieve your password, or unsubscribe
from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users
Loading...