• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Compiling and other questions

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have an application I have written. It is a simple program that has 4 classes that I have written into a single .java file. As expected once compiled I end up with 4 .class files. It runs fine and everything but I have a question. Is there any way I can consolidate those 4 .class files into 1 or at least less than 4 files and still have the app remain runnable? How about making a .jar file? Can you archive the 4 .class files into a .jar and still run the app normally?
Also, is there a way to make an app self executable? So that I can put an Icon on Windows desktop and jave a user simply double click it?
Thanks.
Tom
 
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The answer to all of your questions is the jar format.
If you create a manifest file indicating which class contains the main method, you can create a single "executable" jar containing all your files whch you can place on your desktop and click to run. When you install a modern Java SDK or JRE on Windows it sets up the jar filetype to run java -jar file.jar if clicked.
Look up the documentation for Jar files and the "jar" command.
 
That feels good. Thanks. Here's a tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic