Click here to Skip to main content
15,890,361 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Have made a simple calculator using Java in both .jar and .exe formats using following method:

1) .java test with following code:

Java
import java.util.*;
  class Calccc
  {
      public static void main(String[] args)
      {
          Scanner sc= new Scanner(System.in);    //System.in is a standard input stream
          System.out.print("Start number");
          int a= sc.nextInt();
          System.out.print("Enter second number- ");
          int b= sc.nextInt();
          System.out.print("Enter third number- ");
          int c= sc.nextInt();
          int d=a+b+c;
          System.out.println("Total= " +d);
      }
  }

2) command prompt javac Calccc.java.

3) command prompt jar cvf Calccc.jar Calccc.class.

4) creating manifest.txt in the same folder by Main-Class: Calccc written in the .text plus an extra enter at the end.

5) command prompt jar cmf manifest.txt Calccc.jar Calccc.class.

Then using launch4j application version 3.8 to set a .exe file out of the jar file:

determinig the Output file:
determining Jar.

determining the minimum java -version
clicking on floppy disk icon and save the XML file
clicking on settings icon

But, neither the .jar file nor the .exe file work by double-clicking, but the .jar file works fine within the command line.

What I have tried:

Created multiple of times those fules, but the result didn't change. Also reinstalling Java didn't help either (Java 1.8.0 update 311)
Posted
Updated 24-Jan-22 22:01pm
v3
Comments
0x01AA 24-Jan-22 14:07pm    
From console, try java -cp xyz.jar
Richard MacCutchan 25-Jan-22 3:55am    
That should be
java -jar xyx.jar

1 solution

You cannot use double click of a .jar file as Windows does not know what to do with it. However, double clicking a .exe file should always work. If it does not then there must be something wrong with the file itself. Reinstalling Java would not affect this in any way.

I have never used launch4j so it may well be you missed some step in the conversion process. The launch4j website is probably the best place for help.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900