Comments (32)
I ran into the same problem. To make clearer @so3arbelnox's fix, here's the story: when you build an executable standalone jar with Eclipse, if you select "Package required libraries into generated JAR" Eclipse nests the libraries jars into it, and adds a jar-in-jar-loader.zip
jar to somehow be able to read their content. I believe packr-generated executables do not like that, so you need to extract the library jars into your standalone jar, which is what Eclipse's "Extract required libraries ..." option does.
from packr.
To get at least some output on Windows, you can start the executable with redirection to a log file, like packr.exe > output.txt
. With some luck the output gives you an idea what's going wrong.
from packr.
Where I called Packr with the command line:
java -jar packr.jar -platform windows -jdk "C:/Users/user/.lein-packr-cache/windows.zip" -executable perlin -appjar "target/perlin-0.0.1-SNAPSHOT-standalone.jar" -mainclass "perlin/core/desktop_launcher" -minimizejre "hard" -resources resources -outdir out-win32
I get this output from perlin.exe > output.txt
:
config file: C:\Users\user\Documents\Code\clojure demos\play-clj-demos\perlin\desktop\out-win32/config.json
jar: C:\Users\user\Documents\Code\clojure demos\play-clj-demos\perlin\desktop\out-win32/perlin-0.0.1-SNAPSHOT-standalone.jar
mainClass: perlin/core/desktop_launcher
The my-code-using-Packr's-Maven-version-1.2-generated exe is a different story. This uses lein packr
and my plugin for that build tool that I'm writing:
config file: C:\Users\user\Documents\Code\clojure demos\play-clj-demos\perlin\desktop\out-windows/config.json
jar: C:\Users\user\Documents\Code\clojure demos\play-clj-demos\perlin\desktop\out-windows/perlin-0.0.1-SNAPSHOT-standalone.jar
mainClass: perlin/core/desktop_launcher
vmArg 0: -server
vmArg 1: k
vmArg 2: -Xms512m
vmArg 3: -Xmx512m
The second VM argument I assign in my code is not "k" and is actually "-XX:+TieredCompilation" , which is only enabled on the -server VM and speeds up startup drastically. It was "u" when I checked the output from an earlier exe.
This is extremely weird. Neither displays anything, still.
from packr.
I wonder if the VM argument changng is something related to this native code?
from packr.
Yes, this commit is actually fixing this problem (issue #28).
Please note that the v 1.2 release was done way before that. Did you try a recent version from Github yet? It should be easy to use, just clone, then mvn install
to push it to your local maven cache, then use version 1.3-SNAPSHOT
as a dependency.
from packr.
The latest Packr still has the issue with the "hard" and "soft" resources. This is caused by a space after /jndi in "hard," and a space after both /corba and /jndi in "soft." After compiling a standalone jar of Packr 1.3-SNAPSHOT, I ran it with the same args (although I used out-windows2 as the output directory), then tried out-windows2\perlin.exe > windows-output2.txt
... this created the following file after about 10-15 seconds:
config file: C:\Users\user\Documents\Code\clojure demos\play-clj-demos\perlin\desktop\out-windows2/config.json
jar: C:\Users\user\Documents\Code\clojure demos\play-clj-demos\perlin\desktop\out-windows2/perlin-0.0.1-SNAPSHOT-standalone.jar
mainClass: perlin/core/desktop_launcher
This used the fixed hard profile, and no VM args. However, the -XX:+TieredCompilation did appear in the output (along with the other expected info, like main class) when I requested some VM args from my code using 1.3-SNAPSHOT, although no windows opened, again. This output from the code looks like
config file: C:\Users\user\Documents\Code\clojure demos\play-clj-demos\perlin\desktop\out-windows/config.json
jar: C:\Users\user\Documents\Code\clojure demos\play-clj-demos\perlin\desktop\out-windows/perlin-0.0.1-SNAPSHOT-standalone.jar
mainClass: perlin/core/desktop_launcher
vmArg 0: -server
vmArg 1: -XX:+TieredCompilation
vmArg 2: -Xms512m
vmArg 3: -Xmx512m
Thanks for your help, @code-disaster , I appreciate it.
from packr.
Judging by this output it looks like packr didn't catch any errors.
I'd try to add a very simple HelloWorld main Java class and see if this works. Or replace your main class with a Java equivalent, if this is possible (note: I have zero experience with Clojure). Maybe it's something about Clojure the Java Invocation API it doesn't like.
from packr.
A basic Java demo with System.out.println("Hello, World!");
in the class hello.java.Program does print something, if redirection is on. Without the > redirect, it prints nothing.
Hello, World!
config file: C:\Users\user\Documents\Code\clojure demos\play-clj-demos\out-win32/config.json
jar: C:\Users\user\Documents\Code\clojure demos\play-clj-demos\out-win32/HelloJava.jar
mainClass: hello/java/Program
My Clojure demo is meant to open a window, and didn't have any console out before. I added a (println "Hello, Clojure!")
right at the start of the program, and while it prints that when I run the jar with java -jar, the Packr-generated exe doesn't print anything even with redirection:
config file: C:\Users\user\Documents\Code\clojure demos\play-clj-demos\perlin\desktop\out-win32/config.json
jar: C:\Users\user\Documents\Code\clojure demos\play-clj-demos\perlin\desktop\out-win32/perlin-0.0.1-SNAPSHOT-standalone.jar
mainClass: perlin/core/desktop_launcher
I'm suspecting this may have to do with mainClass shenanigans.
from packr.
Experiencing same issue with a play-clj game when used with packr, it starts eating up CPU, then exits silently, the jar within the folder (the game jar produced with lein uberjar
) works fine.
from packr.
Oh, also, a standard clojure app (lein new app test
) works fine.
from packr.
As said, I don't have experience with Clojure. Is it possible to do the main class in Java, then hand over to your Clojure code?
from packr.
Hmm, I'll try. @tommyettinger is there anyway to make Leiningen use a Java function instead of -main
(from Clojure), it keeps on looking for -main
, but that's illegal in Java by the looks of it.
from packr.
@tommyettinger Never mind, found out what was wrong.
@code-disaster It works! Creating a Java wrapper for the game seems to have worked. Thanks!
from packr.
I'm still puzzled as to why Packr works for Java, but not for Clojure or Scala (I tried a jar built with each). It initially worked with Clojure using an early version of Packr, before the change in launcher.cpp to allow using long arguments to the JRE. I may be able to just downgrade to the earliest maven version of Packr and see if that does the trick.
from packr.
And downgrading to 1.1 works with Clojure but doesn't allow long VM args, and doesn't support 32-bit Linux... hm. There's some problem introduced after 1.1...
from packr.
I just did a quick setup on OS X:
- downloaded clojure-1.6.0.jar
- tried "java -cp clojure-1.6.0.jar clojure.main" to validate that it works
Then I ran different versions of packr using the following config:
{
"jar": "clojure-1.6.0.jar",
"mainClass": "clojure.main",
"vmArgs": [
"-Xmx1G"
]}
- packr 1.1: seg fault
- packr 1.2: seg fault
- packr from github/master: Failed to find class: clojure.main
So on OS X I can't confirm your observation that it works with an earlier version of packr.
But... I have some experimental code written in Rust which I had a similar problem with. It was just not able to find my Java main class. I "fixed" this by using a different approach to search for it, which I found here:
http://stackoverflow.com/questions/20328012/c-plugin-jni-java-classpath
Funny enough, my Rust version of packr-mac runs the clojure.main test above just fine...
So my conclusions for now:
- The method to pass the jar by "-Djava.class.path=", then search the main class with the invocation API seems "unfirm" at best. It doesn't seem to work at all with Clojure.
- If 1.1 runs for you, packr is still somehow inconsistent between Windows and OS X (and probably Linux too).
Regarding your application and Clojure, my best guess right now is that it misses classpath information, e.g. it can't find your main class, or something (clojure-1.6.0.jar?) your main class depends on.
from packr.
Ah, I was using the standalone jars (uberjars) generated by Leiningen (a build tool; the only way most Clojure developers build projects). I have a project called lein-packr that automates the downloading of JREs and calls Packr on an uberjar, and it currently works for 1.1 on windows -- I've generated an OSX build of an older game of mine (it's Packr 1.1 run on an uberjar, and uberjars should be runnable with java -jar uber.jar
) and posted it here. If that .app (compressed to fit under pomf.se's 50 MB limit) doesn't work for you, @code-disaster , on Mac, there could be a number of things wrong, and I don't know what is most likely. My lein-packr project at least works on Windows, but if it doesn't work on Mac/Linux it isn't doing what it should be...
EDIT: If you want the uberjar to test on, it's available here.
from packr.
I am experiencing this problem with packaging for Windows on OSX. It's a LibGDX application.
Here's the packr config:
{
"platform": "windows",
"jdk": "/Users/gancoline/Downloads/openjdk-1.7.0-u80-unofficial-windows-i586-image.zip",
"executable": "Verbivore",
"appjar": "/Users/gancoline/Dropbox/Projects/wordgame/desktop/build/libs/desktop-1.0.jar",
"mainclass": "com/charactory/java/DesktopStarter",
"vmargs": [
"-Xmx1G"
],
"resources": [
"/Users/gancoline/Dropbox/Projects/wordgame/android/assets"
],
"minimizejre": "soft",
"outdir": "/Users/gancoline/Dropbox/Projects/wordgame/desktop/build/win/"
}
And here's the output of redirecting the executable to a file:
config file: C:\Users\kat1675\Documents\win/config.json
jar: C:\Users\kat1675\Documents\win/desktop-1.0.jar
mainClass: com/charactory/java/DesktopStarter
vmArg 0: -Xmx1G
I also removed the trailing spaces in the soft profile as mentioned by @tommyettinger . I did crack open the jar and checked the entry class DesktopStarter was present. The jdk used is the unofficial JDK build at https://github.com/alexkasko/openjdk-unofficial-builds
from packr.
Is this a Clojure application, @charactory?
from packr.
@zackp30 No Clojure, but it has Kotlin in it.
from packr.
To solve the problem we had to create a pure-java wrapper, which literally just calls the Clojure (or in your case Kotlin) API to call your main function from Java.
from packr.
Also having this problem with Windows 64-bit. Tried both oracle JRE and open-jdk. Tried command line, with a .json file, and in code. The generated .exe does nothing but the JAR works fine. I tried piping output into a text file but no output. I am only using Java in my game.
from packr.
With the latest version, you can use the command line interface with "--cli --console" to get output on Windows. See https://github.com/libgdx/packr/blob/master/src/main/native/README.md#command-line-interface for more.
from packr.
Okay I switched to version 2.0 and was able to get output. Seems I was using an old version on Maven.
Loading JVM runtime library ...
Passing VM options ...
# -Xmx1G
Creating Java VM ...
Passing command line arguments ...
Loading JAR file ...
It stops after that. Clicking on the jar itself works fine. Wondering how else I can debug it.
from packr.
Please try again with the "--verbose" parameter, so with "--cli --console --verbose".
There isn't much at this point which can go wrong without generating at least some error message. How's your config.json look like? Please note that with the new version, the main class name must use '.' as separator, not '/'.
from packr.
Thank you that was a big help. I now can see the error, its failing to find the class. I am using '.' insteasd of '/' and it seems to be correct though. Should I not be pointing it to the DesktopLauncher class with the main method in it?
from packr.
Yes, that's the idea. How's the verbose log output look like?
from packr.
Here is what I get from the verbose log output.
Loading JVM runtime library ...
Passing VM options ...
# -Xmx1G
Creating Java VM ...
Passing command line arguments ...
Loading JAR file ...
Adding 1 classpaths ...
# Saedra's_Calling_v0.70.jar
Exception in thread "main" java.lang.NoClassDefFoundError: com/badlogic/gdx/ApplicationListener
Error: failed to load/find main class com.haftstudios.saedrascalling.desktop.DesktopLauncher
Here is my code if it helps.
// Build packr for Windows
Packr.Config config = new Packr.Config();
config.platform = Platform.windows64;
config.jdk = "C:\\Users\\Matt\\Downloads\\openjdk-1.7.0-u80-unofficial-windows-amd64-image.zip";
config.executable = "Saedras_Calling_v0.70";
config.mainClass = "com.haftstudios.saedrascalling.desktop.DesktopLauncher";
config.vmArgs = Arrays.asList("-Xmx1G");
config.classpath = Arrays.asList("C:\\Users\\Matt\\Downloads\\Saedra's_Calling_v0.70.jar");
config.resources = Arrays.asList("C:\\Users\\Matt\\workspace\\SaedrasCalling\\android\\assets\\");
config.outDir = "out-windows";
try
{
new Packr().pack(config);
}
catch (IOException exception)
{
System.out.println("It didn't work: " + exception.getMessage());
}
Thanks for looking into it and apologies if I am doing something really stupid.
from packr.
You got an apostrophe in your jar files name. Pretty sure that makes it
explode.
On Feb 7, 2016 2:58 PM, "so3arbelnox" [email protected] wrote:
Here is what I get from the verbose log output.
Loading JVM runtime library ...
Passing VM options ...-Xmx1G
Creating Java VM ...
Passing command line arguments ...
Loading JAR file ...
Adding 1 classpaths ...Saedra's_Calling_v0.70.jar
Exception in thread "main" java.lang.NoClassDefFoundError: com/badlogic/gdx/ApplicationListener
Error: failed to load/find main class com.haftstudios.saedrascalling.desktop.DesktopLauncherHere is my code if it helps.
// Build packr for Windows
Packr.Config config = new Packr.Config();
config.platform = Platform.windows64;
config.jdk = "C:\Users\Matt\Downloads\openjdk-1.7.0-u80-unofficial-windows-amd64-image.zip";
config.executable = "Saedras_Calling_v0.70";
config.mainClass = "com.haftstudios.saedrascalling.desktop.DesktopLauncher";
config.vmArgs = Arrays.asList("-Xmx1G");
config.classpath = Arrays.asList("C:\Users\Matt\Downloads\Saedra's_Calling_v0.70.jar");
config.resources = Arrays.asList("C:\Users\Matt\workspace\SaedrasCalling\android\assets");
config.outDir = "out-windows";try
{
new Packr().pack(config);
}
catch (IOException exception)
{
System.out.println("It didn't work: " + exception.getMessage());
}Thanks for looking into it and apologies if I am doing something really
stupid.—
Reply to this email directly or view it on GitHub
#33 (comment).
from packr.
Just tried removing that but have the same error as above. Also removed '.' and '_' for good measure as well.
from packr.
"java.lang.NoClassDefFoundError: com/badlogic/gdx/ApplicationListener" very likely means that it found your application's main class, but failed to invoke it because it misses other dependencies - core libGDX classes, so it seems.
I'm not sure though why it would work when run with "java -jar Saedra's_Calling_v0.70.jar" in your case.
from packr.
Just fixed it! For some reason it was not working when I exported the JAR file with "Package required libraries into generated JAR". I changed it to "Extract required libraries into generated JAR" and it seems to work. Strange thing is both versions of the JAR work if I run them.
from packr.
Related Issues (20)
- XstartOnFirstThread hangs forever on OSX HOT 1
- LWJGL3 crashes on OSX HOT 4
- Packr cannot recognise `jrePath` Temurin JRE and JDK zips for Windows HOT 8
- Load configuration file relative to executable location, not working directory HOT 1
- Can you create Linux binary that makes use of installed Java on Linux instead of packaging one with packr?
- How to make generated app to use current working dir as its working dir instead of app's dir?
- FEATURE REQUEST HOT 1
- Consulting: Complicated packaging methods
- Packing with Oracle JDK causes error HOT 2
- Mac keeps throwing permission denied HOT 1
- Error 503 from https://artifactory.nimblygames.com while building HOT 1
- Version 4.0.0 missing from artifactory HOT 2
- Error when execute .exe file
- classpath is empty when retrieving it.
- Frame blurry when starting with bundled launcher
- Can you add an option to remove the previous out directory if it exists?
- Generated .exe does nothing HOT 8
- packr repo seems not to work HOT 6
- 关于windows打包的问题
- 关于linux/macos打包的问题 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from packr.