Startup Script for Java [closed] - java

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I am trying to figure out to make a startup script for my java application, I tried making an installer for this in advanced installer. Over there I added the jvm arguments but it did not work, well that is a separate issue...
What I am asking is: Is there a script that I can place along with my JAR file in C Drive so that from the Desktop's Shortcut I run that script and that in turn opens the JAR with increased heap space?
I couldn't neither find how to make startup script on Google, Sorry I am not too familiar/aware of Bat file scripting
This question is somewhat sort of an extension to my last question

You could create a Batch script file ".bat" that runs a command like -
java JVM_Arguments -jar yourJarFile.jar
pause
pause is optional if you want to stop the command prompt from closing at the end of jar execution - to check for errors or just the output of the execution.

java -jar PATH_TO_YOUR_JAR in a batch file should do this. but the condition is your jar should be executable.

Typically a JAR has external dependencies which are not packaged as a part of it, but needs to be provided to the Java Virtual Machine when running the JAR (they need to be in the classpath)
If you want to run your class from the command line you have several solutions:
Create a batch script as suggested above or in Run class in Jar file . You will have to carefully provide with the -cp argument all the jars required
Create a "fat" jar that contains inside all the classes from external jars. This might generate a JAR of several megabytes if you need many libraries. In such a case writing the batch script will not require you to add all the jars, because they will be contained in the fat jar
Launch the application using a build system, capable of writing for you the call to the java executable with the right parameters
The general suggestion is that you get familiar with class loading in Java and just after with build systems, which are going to become your best friend whenever developing a non trivial application. I would probably suggest you start with Maven, even if today better tools such as Gradle or SBT are available

Related

How to properly build native executable file from jar? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I have had Intellij IDEA generate an executable jar for me and executing the jar using java -jar command works great.
But when I try to wrap this jar into an exe file using launch4j, various errors happen. First there was an error saying "Could not find or load main class".
After looking at this and this questions I thought the problem is about pathnames or classnames. However, that was not the case. Apparently, the main class was found, but couldn't be loaded because there was no pathnames to Java and JavaFX runtimes.
After adding rt.jar and jfxrt.jar to classpaths another error appeared:
"JavaFX runtime components are missing, and are required to run this application"
And now I really don't know what to do. I downloaded the latest jre (8.0.221) but nothing changed. jfxrt.jar is a JavaFX runtime to my knowledge, but it seems like the application doesn't recognize it as one.
Any recommendations for deploying, suggestions for my project or remarks are welcome and appreciated. Thanks!
I achieved what I wanted by using one of launch4j built-in functions. In section JRE there is an option for bundled jre path. And to create native app launcher with bundled jre you just have to specify the path of jre. This took me 5 days to find.
You can make .exe file using Inno tool set up.
I have used this there was no error, exe runs fine.
Link :- http://www.jrsoftware.org/ishelp/

How to update native built JavaFX Application

I am building a JavaFX application in Intellij that will be built and distributed with an .exe installer and will be ran as an exe Application. I have been trying to find a way to allow for remote updates, but I have only found resources that update a jar file by using another jar file hosted on a website. Is there a way to allow for remote updates to a exe JavaFX application? I have though about using update4J, but sadly I have no idea how to implement it, use it, or if it will even work with exe applications. I have tried to use FXLauncher, but I am not able to use JavaFX with maven as an error occurs whenever I try adding maven framework to the project.
I am the developer of update4j.
The framework used to be complex and hard to use, but the last release (1.2.2 at time of writing) significantly simplified things leaving only one pain point, namely, generating a configuration.
So for starters, launch the framework using it's own main method:
# on classpath
$ java -jar update4j-1.2.2.jar
# on modulepath
$ java -p update4j-1.2.2.jar -m org.update4j
And read the output.
Creating the configuration is done using a builder, I'm still documenting it but the class javadoc for Configuration is quite complete.

How can I make a program executable by double clicking? [duplicate]

This question already has answers here:
How to make an executable JAR file?
(5 answers)
Closed 8 years ago.
I wrote a JAVA program for my wife to compare coupons stacked with sales on different item sizes to save her time on her shopping-trip-planning. Now I need to put it on her computer in such a way that she can double-click something, and have the program run. I'm not finding anything good on the interwebs (like a decent step by step).
It is a simple program, one class with a nested class, and various imports of swing, awt, and text.
Since it's my wife's computer, I can make sure that she is running the appropriate JRE. Thanks in advance for any help.
You can use Launch4j application. That convert executable jar file to windows native executable application.
You can also embed JRE with it so if JRE is not installed on machine the application will run.
you can also add some other mechanism to it also like loading image, icon, etc.
I assume you are using Eclipse. In this website they given it very clearly for eclipse.
Create Executable files in eclipse
Export it to (or create a) executable Jar.
Most IDE's will do this (I think you have to dig around Eclipse a little) or take a look at Packaging Programs in JAR Files and Setting an Application's Entry Point if you want to do it by hand
Most GUI OS's will run the Jar via a double click.
You could also investigate generating a native executable wrapper, which will make the program "look" more familiar to the user, including launch4j or exe4j or Packaging a Java App for Distribution on a Mac depending on your target platform
Use NetBeans and simply 'Build' the jar file. This will produce an executable file within the 'dist' folder of your project.
Eclipse is the same however slightly more hidden.

IzPack, can it output a single executable jar?

I found some great tutorials for IzPack and it works great at installing my program into a folder. Is it possible to have the contents of those folder wrapped into an executable jar using IzPack? My goal would be to have that executable jar call my python script which launches the application. Let me know what I can do, thanks.
I don't think so. Not because IzPak did not have the capability to do that (it obviously creates the installer's jar), but because it was not designed to do so, AFAIK.
If you want to pack various jars in a single jar file, then you should attack this problem in the build phase of your project. If you use Netbeans, then this link will be useful:
http://java.sun.com/developer/technicalArticles/java_warehouse/single_jar/
About executing the python script... are you using Jython? If not, take into account it is quite difficult to distribute a python program, many apps written in python distribute the interpreter and its required dll's with them.

Netbeans Ant sign 2 jars separately?

I have a large netbeans java project (with multiple applets) that currently gets built into one jar through a netbeans built-in Ant script. I would like to obfuscate this jar and then sign both the original and the obfuscated version. My question is, what do I make my target depend on? If I do the following:
<target depends="jnlp" name="-post-jar" description="obfuscate jar.">
Then the target gets executed AFTER the initial jar has been signed. Evidently, this invalidates the signing process done to the first jar. Does anyone know how to create a target that happens between the jar-build and jar-sign processes? Or should I just take the current signing process out of netbeans and write it myself in this new "-post-jar" target?
I've come across this But I don't know how to apply it without editing the built in ant scripts... Any help is appreciated.

Categories