Make JAR as a standalone executable


Is there a way to convert JAR lib into JAR standalone? I need to find a standalone java executable that convert PDF into TIFF and I've found these JARs: <a href="http://www.icefaces.org/JForum/posts/list/17504.page" rel="nofollow">http://www.icefaces.org/JForum/posts/list/17504.page</a>

Any ideas?


Easiest might be to create another Jar with a Main() entry point, and then just use the java.exe executable to run it:


> java.exe -cp MyJarMain.jar;MyPDFJar.jar com.mydomain.MyMain myPDF.pdf

Where MyMain is a class with a Main static method.

You'll need something with a main entry point to pass in and interpret some command line arguments (myPDF.pdf in my made-up example)


You could do an assembly (are you using maven?) and make sure the Main-Class entry in the manifest.mf points to the main class.


Since there is no main-Method, you have to write one, or write a whole new class to call the class/method TiffConver.convertPDF .

The question is, how you're going to use it. From the command line, you need no executable jar. From the Gui, maybe you want to pass a file to be converted by drag and drop? Then you should take the parameter(s) passed to main as Input-PDF-Names (if they end in .pdf) and pass the names iteratively to TiffConverter, for "a.pdf b.pdf" => TiffConver.convertPDF ("a.pdf", "a.tiff"); TiffConver.convertPDF ("b.pdf", "b.tiff");

TiffCoverter will silently overwrite existing tiffs, so check that before or change the code there - this is clearly bad habit, and look out for more such things - I didn't.

/* * Remove target file if exists */ File f = new File(tif); if (f.exists()) { f.delete(); }

Maybe you wan't to write a swing-wrapper, which let's you choose Files interactively to be converted. This would be a nice idee, if no filename is given.

If the user passes "a.pdf xy.tiff" you could rename the converted file to xy, as additional feature.

Without a main-class, however, a standalone jar would be magic.

However, building a native executale is almost always a bad idea. You loose portability, you don't profit from security- and performance improvements to the JVM or fixed bugs. For multiple programs you need always an independend bugfix, which you might have to manage yourself, if you don't have a package-management as most linux distros have.

<hr />

after clearing some questions:

public static void main (String [] args) { if (args.length == 1 && args[0].endsWith (".pdf")) { String target = args[0].replaceAll (".pdf$", ".tif"); convertPDF (args[0], target); } }

This method you put into TiffConvert. It will allow you to convert a simple pdf-File, and generate a tif-File with the same basename but ending in .tif, silently overwriting an existing one of the same name.

I guess you now need to know how to start it?


  • Python BZ2 IOError: invalid data stream
  • Display Manifest properties in JSF2
  • find the region part of live using c#
  • JENKINS: ERROR when I try to use an older JDK for a specific maven project
  • Regarding client side code generation from WSDL
  • JConsole Main class
  • maven jboss-as:start A required class was missing … org/sonaty…/ArtifactResolutionException
  • Why can't I use non-integral types with switch [duplicate]
  • How dotnet build chooses the output name
  • How to display the images in listview
  • How do you create a Fuseki SPARQL server using the Apache Jena Java API?
  • EditText is covered by Keyboard
  • ConnectivityManager.CONNECTIVITY_ACTION deprecated
  • Translating C# to PowerShell in InterIMAP
  • Get the number 18437736874454810627
  • Is there a way to dynamically embed PDF Files in a JSP pulled from the file system?
  • Creating PDF from TIFF image using iText
  • hide missing dates from x-axis ggplot2
  • Android Studio Can't Find tools.jar
  • How to detect interior vertices in groups of 2d polygons? (E.g. ZIP Codes to determine a territory)
  • Installed module is empty
  • x64 applications using gdi+: what are the consequences on performance?
  • chrome.tabs.executeScript only fires when the Developer Console is open
  • Illegal mix of collations for operation for date/time comparison
  • How reduce the height of an mschart by breaking up the y-axis
  • MySQL WHERE-condition in procedure ignored
  • sending/ receiving email in Java
  • Trying to switch camera back to front but getting exception
  • Traverse Array and Display in markup
  • How to delete a row from a dynamic generate table using jquery?
  • Proper way to use connect-multiparty with express.js?
  • Free memory of cv::Mat loaded using FileStorage API
  • C# - Getting references of reference
  • Angular 2 constructor injection vs direct access
  • Java static initializers and reflection
  • unknown Exception android
  • Checking variable from a different class in C#
  • Programmatically clearing map cache
  • Observable and ngFor in Angular 2
  • Unable to use reactive element in my shiny app