Distributing java application

bundle jre with java application
self-contained java application
launch4j
how to package java application
java packaging tools
publish java application
bundle java application
how to deploy javafx desktop application

I have recently developed some java applications that i want others to run on their machines. I did some research and now know that to distribute java code you need to create .jar file. Well i did that, but when I am distributed those file it runs on some computers but on others it return an error saying: "Main class could not found".

  1. Is there any problem with JRE version.
  2. How would a user know that on which version he/she should run the application.
  3. can i package the correct jre version with my app/jar file. how??
  4. Are jar files not compatible with other version of jre except in which they are compiled.

Option1: Create a manifest file with entry as below and include in the jar:

     Main-Class: MainProgram

Option2: Just mention your Main class name while running the program e.g. if you jar name is myprogram.jar and main class is MainProgram then run the program as below:

        java -cp myprogram.jar MainProgram

If your MainProgram takes some arguments, them pass them as well in the command line e.g.

       java -cp myprogram.jar MainProgram argument1 argument2

Packaging and Distributing Java Desktop Applications, Note that Java Web Start is deprecated and will be removed in the future, this was a great way to deploy java desktop applications. Sounds like Oracle is trying to� InstallBuilderallows you to easily distribute Java applications and bundle a JVM (although itself does not require Java, so as you mention you will never get errors because the end user does not have a JVM in the machine).

Some of the SDKs (like Eclipse) have a function for the creating of jar-files. If you work one the console this will maybe help you to create stable jar-files:

'jar cfm className.jar MANIFEST.MF className.class'

Self-Contained Application Packaging, How to distribute your Java Applications on all desktop platforms. 2,357 views2.3 K views Duration: 3:06 Posted: Apr 26, 2018 Distributing Java applications Java™ applications typically consist of class, resource, and data files. When you distribute a Java application, your software package probably consists of the following parts:

  1. This should not matter, except for point 4.
  2. You would have to tell them the minimum required version.
  3. You could, but then you would probably have to create an installer, which is even more complicated than a jar.
  4. In general yes, if your user has a VM at least the version you compiled with. The class files that you package inside the jar are targeted to some version of the JRE and their format changes every now and then. Higher versions of the JRE support lower version class files.

The error message indicates that the JRE can't find your main class. From the comments it looks like you did not specify the manifest correctly. Is it contained inside a META-INF directory inside the jar? What does jar -tf my_jar.jar tell you?

If you're worried about JRE versions, try specifying a lower target version in your javac command. You do this by adding -target xx to your javac invocation and possibly also -source xx. Have a look at javac -help for a description of the flags.

How do people topically distribute Java desktop apps? : java, Learn how to distribute desktop java application to your clients by creating executable or Duration: 1:24 Posted: Nov 7, 2015 Distributing a Desktop Java Application Outer Colony’s Requirements. Before getting into my experimental solutions, it’s important to understand the general Java Web Start. Java Web Start is a technology directly from Oracle that’s used to distribute Java applications via the Self Contained

How to distribute your Java Applications on all desktop platforms , Java Web Start is a technology directly from Oracle that's used to distribute Java applications via the internet. At first glance, it seemed like the� You CAN bundle a JRE with a Java application, provided that you follow certain conditions. (If I recall correctly, this is covered by the standard Sun/Oracle license that you agree to when you download the JRE. I think the phrase is a "binary distribution" or "binary redistribution".)

Distribute your Java Application by Creating Executable jar, Distributing a Java application on multiple JVMs allows to process more user requests just by adding more hosts. Distributed systems can be incredibly powerful,� You can distribute the application by following these steps: Create a zip file that contains the application JAR file (AnotherGrep.jar) and the accompanying lib folder that contains swing-layout-1.0.jar. Send the file to the people who will use the application.

Distributing a Desktop Java Application |, The Java ecosystem provides a standard format to distribute all Java classes that are part of the same application. You can package these� If an application includes Java you might not be able to tell that it is a Java-based application. If an application requires that you provide a copy of Java it will list so in the application's documentation under requirements or pre-requisites.

Comments
  • How did you create the JAR (what options, and did you include a manifest with Main-Class) and how are you trying to run the program?
  • I included the manifest.mf file with the jar using "jar xyz.jar manifest.mf *.class" command in cmd . I need that it should run on any machine by just double clicking on it.It runs on some machines which have jre 7, but otherwise on lower versions it gives above mentioned error.
  • What JDK version are you compiling it with?
  • +1; good question. You're facing a general problem when it comes to software distribution, especially in Java. Sadly, it's not that easy to solve. During development and build you may have to make (and communicate) certain decisions (min/max JRE version, JRE vendor, OS'es supported, OS behavior like double-click a JAR, etc.). All those factors influence your build process. I'd say you just have to work it out - apologies...
  • unless you have some code which is specific to JDK7 it would be better to compile with the lowest version of JDK possible. Then anyone who has a JRE at a higher version can use it.
  • Well i did that an it happens to run on some machines but on some other machines whose jre version is not the same as the app was compiled in it does not work
  • @AnirudhChhangani: When its not running, are you sure of getting Main class not found error?
  • Yeah absolutely...the case is when I upgrade the users JRE version to the version the app was compiled in it runs...
  • @AnirudhChhangani I'm willing to bet that the machines where it doesn't work have an older version of the JRE than the JDK for which you compiled it. The simplest solution is to set the --target flag for an older version of Java so that your program can run on them
  • If you are using ant, then refer javac task. It has an attribute as target. Refer javac cross compilation specification. This also has target option.
  • the manifest is in the META-INF the above command gives me the list of all the classes inside the jar file. how can i compile a program in a lower version..can u specify the command
  • Just add -target my_version to your javac command. You need to be sure that you don't use any API from a newer version though.
  • Have a look at javac -help.
  • When I try to compile it with the command : "javac -target 1.6 xyz.java" an error returns saying target release 1.6 conflicts with default source release 1.7. how do i correct this??