0

I am on a Windows platform with a JDK 16.0.1 environment. I created a jar file of my java code by using Java with Ant on my NetBeans. These are the command lines that I used to create DEB file from the jar file:

jpackage --input D:\Fida\Codeblocks\Java\Projects\MultipleClass\dist\MultipleClass.jar --name Multiple Class --main-jar D:\Fida\Codeblocks\Java\Projects\MultipleClass\dist\MultipleClass.jar --main-class parent.Parent --type deb --java-options 'enable-preview'

Here, the input attribute is where my jar file exists. The name attribute is what should be the name of the DEB file once produced. The main-jar attribute is also the location of the jar file that I want to convert to DEB. The main-class attribute is the main class of the jar file, in this case 'parent.Parent.' I got it from the Manifest.mf in the jar file. The type attribute is what I want to convert the jar file, in this case 'deb.' Finally, the options attribute(which I don't understand. I just copy-pasted the whole command from this site).

But when I hit enter, I get this error: Error: Invalid Option: [Class]. And I am sure that there is a mistake somewhere. I even ran the same command on my Linux system with the same JDK version. Then I got this:

java.nio.file.FileAlreadyExistsException: /tmp/jdk.jpackage16852425662219297051/images/src/MultipleClass/lib/app

I don't know what do now. Besides the solution to this error, I would also appreciate any other suggestions for converting jar to Linux executables.

1 Answers1

1

Multiple Class is two arguments (aka tokens or words) in both Windows (CMD and PS) and any Unix shell. Error: Invalid Option [Class] tells you the second argument was not treated as part of the --name value but instead as a new option, and it isn't an option so that makes it invalid. To make it one argument and thus valid either omit the space or put quotes around it (on CMD only " ", on PS or nonweird Unix either " " or ' '). Since it's customary for package/installer file names on at least most Unix variants, including deb and rpm, to not contain space, the former is probably better.

But as correctly stated in step 4 of the page you link, jpackage must be run on the OS type you are targetting; you can only package 'deb' (or 'rpm') from Linux. And --input should be the directory containing the jar(s) not the or an actual jar, as indicated by the trailing slash on that page.

dave_thompson_085
  • 34,712
  • 6
  • 50
  • 70
  • As you said, I made a few corrections. (1) I used the jpackage command from my Linux terminal. (2) I removed the 'MultipleClass.jar' from the --input attribute since you said that it should contain only the directory where the jar exists. And then, the final command I entered was this: jpackage --input /home/kali/Desktop/ --name MultipleClass --main-jar /home/kali/Desktop/MultipleClass.jar --main-class parent.Parent --type deb --java-options 'enable-preview'; After I hit enter, it takes about a minute to complete the command. But I cannot find the DEB file anywhere. What is wrong? – Programmer Hobbyist Jun 19 '21 at 11:34
  • It should be in the working directory, unless there was an error you missed somehow. – dave_thompson_085 Jun 22 '21 at 12:43