I made some little programs with Swing-components in JRuby. Now I want to convert these to .jar-archives.
The first option I found is warbler: https://github.com/jruby/warbler
Making a jar should be as simple as:
$ chmod a+x bin/mylittleprogram.rb
$ warble jar
But warble is aborted with an error: "can't modify frozen string"
same issue as here: https://github.com/jruby/warbler/issues/76
I'm a newbie and, frankly speaking, I don't get from the thread at github what to do (like: look for x in file y and change it to z) to make it work. Like the guy who started the thread, I have an Ubuntu OS (11.04) und MRI and JRuby installed.
I also found rawr: http://rawr.rubyforge.org/
Making a jar should work as follows:
rawr install
rake rawr:jar
java -jar package/jar/your_jar_file.jar
In my case, I get an error:
Exception in thread "main" org.jruby.exceptions.RaiseException: (LoadError) no such file to load -- main
My Question: Which of these two options will be easier to use?
It would be also very helpful, to get an explanation what warbler and rawr do in the background.
Many thanks in advance!
Rawr is quite simpler for the standalone app. In your case, I guess you haven't specified the main class yet. You should check it on build_configuration.rb
# The main ruby file to invoke, minus the .rb extension
# default value: "main"
#
c.main_ruby_file = "hello"
where in my case, hello.rb is the main ruby file.
According to the Warbler bug you refer to, the fix has been merged, but it looks like no gem has been released since.
I suggest you try building a latest warbler gem from the github source, as per this question
Related
I should preface this by saying I'm a novice who got in way too deep trying to make a Swing app an exe. After reading the docs I've sort of gleaned what the meanings of all the parameters are, but I'm still confused. What I'm trying to achieve is an application that can be double clicked and launch the GUI, without creating a JRE (if it is not necessary) No jfx so it is non modular.
I tried to use these following commands:
jpackage --type app-image -i "C:\Users\User\quadAdventGame\out\artifacts\quadAdventGame_jar" -n quadGameTest --main-class Main --main-jar quadAdventGame.jar
Then using that app image:
jpackage -n name --app-image "C:\Users\User\quadGameTest"
This resulted in two things: The installer ran, Norton Antivirus flagged it, saying it stopped the process, and then I told Norton to let it go. Then the installer failed to run, saying it had no access to "main.msi" in my Local disk. I also tried direct msi installing,
jpackage --type msi -i "C:\Users\User\quadAdventGame\out\artifacts\quadAdventGame_jar" -n quadGameTest --main-class Main --main-jar quadAdventGame.jar
which simply doesn't run when double clicked.
BTW, here's what the generated folder looks like, which seems like it may be wrong.
My questions would be:
Is Norton some how involved in the stoppage of my app from running? I'm not sure what Main.msi is in my temp folder.
Are my commands wrong? It seems like they are not correct for what I want to achieve, which is just a simple runnable application. The code is baby stuff, this is literally just me trying to prove I can do this. Does the main class input need to have the .java prefix? It honestly might be me just naming stuff wrong, but the generated folders have a jar that runs fine.
If so, how can these commands be remedied?
I am on the Oracle JDK 14.
Hello again Stack Overflow!
I am currently working on a Java program that is essentially a digitized character sheet for a Dungeons and Dragons style adventure. I'm currently learning how to use IntelliJ IDEA, and while I haven't been able to figure out how to create a standalone executable .jar file, I have been able to find a workaround in the form of a .bat file that I have nicknamed rubberglove.bat (because if you can't open a jar, you use a...).
However, as in my previous post, I've run into a problem, as one of my new players uses a Mac, and since I don't know if it's possible to run rubberglove.bat in a non-Windows environment, I'll probably have to translate it into something MacOS can understand. However, I've never owned a Mac, so I'm not sure what the file extension even is, let alone what to put inside.
The contents of rubberglove.bat are shown below:
java -jar [program_name].jar
What would the Mac equivalent of this file and the commands inside? Thanks in advance for all your help!
Create a file called rubberglove (or rubberglove.sh, the file suffix is optional). And then set the execute bit. Something like
$ cat << EOF > rubberglove
#!/usr/bin/env bash
java -jar [program_name].jar
EOF
$ chmod +x rubberglove
$ ./rubberglove
Error: Unable to access jarfile [program_name].jar
Adjust "[program_name]" as needed.
I'm developing an application in java, and in this one, I use jython-standalone (Jython for untold reasons, its goal being to ease some scripting within the application).
I would like to have access to NumPy, and it seems that JyNI provides such capabilities.
I found many posts explaining how to start a Jython project using JyNI, but none on how to include the .jar or something in the application so that it is available when needed.
As stated on JyNI, java -cp build/JyNI.jar -jar jython.jar does not work.
Is there a way for me to use JyNI when executing some Jython code through a PythonInterpreter ?
You should be able to start the live interpreter by executing the class org.python.util.jython.
On Linux, OSX:
java -cp jython.jar:build/JyNI.jar org.python.util.jython
On Windows:
java -cp jython.jar;build\JyNI.jar org.python.util.jython
Alternatively, one can use Jython's start script:
jython -J-cp build/JyNI.jar
This info is taken from https://github.com/Stewori/JyNI#running-jyni, but leaving out the script argument someFile.py.
If you want to explicitly leverage the interpreter through Java code, you will surely have some way to launch your overall application. Make sure to have JyNI.jar and the folder containing its binaries on classpath in that command. Jython should be running with JyNI support then.
A side-note: Be sure to use Jython 2.7.1 and NumPy >= 1.12. Version mismatch of these prerequisites is a common cause of failure.
Background: Ubuntu 64bit machine. I need to call a matlab-based jar from django(deployed on apache). Here is the problem, when I run the command on the shell, it works; however, when I call subprocess.Popen({{cmd}}) inside django code, an exception is thrown.
Edit: I try to open a python shell and call subprocess.Popen({{cmd}}). I write a single python script file and put the same code in it. They all work. It's so weird that the code just fail when run on django!!!!!!
For details:
The cmd: java -jar A.jar param1 param2 param3 param4
When run directly in shell, everything is normal. When run with python code, the exception is:
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.mathworks.toolbox.javabuilder.internal.MCRConfiguration.getProxyLibraryDir(MCRConfiguration.java:178)
at com.mathworks.toolbox.javabuilder.internal.MCRConfiguration$MCRRoot.get(MCRConfiguration.java:77)
at com.mathworks.toolbox.javabuilder.internal.MCRConfiguration$MCRRoot.<clinit>(MCRConfiguration.java:87)
at com.mathworks.toolbox.javabuilder.internal.MCRConfiguration.getMCRRoot(MCRConfiguration.java:92)
at com.mathworks.toolbox.javabuilder.internal.MCRConfiguration$ModuleDir.<clinit>(MCRConfiguration.java:66)
at com.mathworks.toolbox.javabuilder.internal.MCRConfiguration.getModuleDir(MCRConfiguration.java:71)
at com.mathworks.toolbox.javabuilder.internal.MWMCR.<clinit>(MWMCR.java:1466)
at autoBlockJava.AutoBlockJavaMCRFactory.newInstance(AutoBlockJavaMCRFactory.java:83)
at autoBlockJava.AutoBlockJavaMCRFactory.newInstance(AutoBlockJavaMCRFactory.java:94)
at autoBlockJava.AutoBlockJavaSharedMCRFactory$3.call(AutoBlockJavaSharedMCRFactory.java:95)
at autoBlockJava.AutoBlockJavaSharedMCRFactory$3.call(AutoBlockJavaSharedMCRFactory.java:93)
at autoBlockJava.AutoBlockJavaSharedMCRFactory.getInstance(AutoBlockJavaSharedMCRFactory.java:72)
at autoBlockJava.AutoBlockJavaSharedMCRFactory.newInstance(AutoBlockJavaSharedMCRFactory.java:93)
at autoBlockJava.manualMain.<init>(manualMain.java:97)
at autoblock.AutoBlock.main(AutoBlock.java:29)
Caused by: java.lang.NullPointerException
at com.mathworks.toolbox.javabuilder.internal.MCRConfiguration$ProxyLibraryDir.get(MCRConfiguration.java:143)
at com.mathworks.toolbox.javabuilder.internal.MCRConfiguration$ProxyLibraryDir.<clinit>(MCRConfiguration.java:173)
... 15 more
I'm totally confused. I really don't know what's the reason for it now.
I think your problem has nothing to do with Python, Django, or Java, but only with the way Matlab calls external programs.
On Linux, Matlab sets the variable LD_LIBRARY_PATH in the environment of child processes. As an example, on my system:
>> getenv('LD_LIBRARY_PATH')
ans =
/opt/MATLAB/R2013a/sys/os/glnxa64:/opt/MATLAB/R2013a/bin/glnxa64:/opt/MATLAB/R2013a/extern/lib/glnxa64:/opt/MATLAB/R2013a/runtime/glnxa64:/opt/MATLAB/R2013a/sys/java/jre/glnxa64/jre/lib/amd64/native_threads:/opt/MATLAB/R2013a/sys/java/jre/glnxa64/jre/lib/amd64/server:/opt/MATLAB/R2013a/sys/java/jre/glnxa64/jre/lib/amd64
Apparently, this setting makes some system libraries (or just the correct version of glibc?) unavailable to child processes:
>> !konsole
konsole: /opt/MATLAB/R2013a/sys/os/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by /usr/lib/libstreamanalyzer.so.0)
konsole: /opt/MATLAB/R2013a/sys/os/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by /usr/lib/libstreams.so.0)
The problem can be resolved by explicitly unsetting LD_LIBRARY_PATH by
setenv('LD_LIBRARY_PATH')
I'm not sure for what purpose Matlab sets LD_LIBRARY_PATH, and I'd guess that some special functionality must be broken by unsetting it. However, I've had the line above in my startup.m for years now, and I haven't run into any problems.
See also: Start application from Matlab
I launch the following command line (process) from a Windows VC++ 6 program using CreateProcess (or _spawnv()):
java -cp c:\dir\updates.jar;c:\dir\main.jar Main
and class updates in updates.jar (overiding some in main.jar) are not read or found. It is as if the updates.jar library cannot be found or read.
If I launch the same line from a shortcut, or from the command line proper, everything IS found and executes properly.
If I launch a JVM from the command line, keep it running, AND THEN launch the executable stub (above), then everything works OK also. (This makes it look like the issue is a file rights thing).
Any insight would be greatly appreciated!
--Edward
Try using Microsoft's FileMon utility to figure out what's happening. Set the include filter to "updates" to focus in on the problem.
http://technet.microsoft.com/en-us/sysinternals/bb896642.aspx
Have you tried this on another machine? Another OS? Which JVM are you using? Have you tried different JVMs?
Can you provide us with a minimal example which demonstrates the problem?
Thanks jdigital!
I tried FileMon and it showed me what I was doing wrong. The executable calling CreateProcess() had an unclosed file handle to updates.jar from an attempt to copy the update JAR earlier. Bad code that works in the production environment, but not in the test environment.