• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Distributing Code

 
Ranch Hand
Posts: 488
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've been coding for a while, but I haven't had to distribute anything until now. How do I distribute Java code that I can be sure will run on someone elses machine? I don't want them emailing me that it doesn't work only to find out they need Java installed or something. Will a simple JAR file work or do I need to turn it into an exe somehow? Does it need to install somewhere on their pc so that filepaths are setup correctly? I am basically confused on the entire process but want as simple a solution as possible.

Thanks in advance!
 
Ranch Hand
Posts: 490
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If it is a java application, they will need a proper JRE installed. This requirement should be obvious. If you don't want a JVM to be required don't use Java, use C or C++.

It is possible to compile java code to a native executable, but from what I have read it isn't very good.

You don't need to bother with formal install procedures, that breaks platform compatibility in the sense the windows installer will be different then a RPM, which will be different then a DEB file.

Eclipse has it right, download, unzip where ever you want, and run it. The entry point is an ELF executable to get things started(which isn't necessary with simpler apps- an executable JAR will be OK) and of course it comes crashing down if it can't find a JRE.
 
Brian Legg
Ranch Hand
Posts: 488
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rusty Shackleford wrote:It is possible to compile java code to a native executable, but from what I have read it isn't very good.



So, if I don't want the user to have to install anything (this includes JRE and JVM) then my only option is an exe, right?

I was confused about the last sentence about an ELF file and a JAR..... more details please?

Thanks for the reply.
 
Rancher
Posts: 600
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

So, if I don't want the user to have to install anything (this includes JRE and JVM) then my only option is an exe, right?



Brian, I'm not sure that's really realistic. With Java software, there is some expectation that a JRE is present. Personally, I've never come across an instance of a Java program turned into an .exe-type file.

John.
 
Brian Legg
Ranch Hand
Posts: 488
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Fair enough.

So, am I to understand that if I want to give someone some software to run then they must have a JRE and JVM installled? And if so, can I just deliever a JAR file which they can double click to run?

I want to give a completely untechnical person some code I wrote via email attachment. I would idealy like them to be able to just save it off to thier desktop, double click it, and have it run as expected. If it is more complicated then that then I need to write a simple batch installation file with the other things they'll need.

When I first started with java I installed JRE, JVM, JDK, etc, all at the same time so I am not sure which ones are needed to do what. It works in my environment..... and that's about all I know when it comes to distributing applications. Sad, I know... but you have to start somewhere, right?

All help appreciated.

And thanks as always!
 
John de Michele
Rancher
Posts: 600
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Brian:

They'll need the JRE at the very minimum, which has the JVM. If you want them to have something that's clickable, send along a batchfile that will run the following command:

java -jar <name_of_jar_file>.jar

John.
 
Brian Legg
Ranch Hand
Posts: 488
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Great, thanks!

This still concerns me though. Traditionally applications are distributed with an .exe file which runs the program. The idea that Java doesn't/can't be turned into an .exe is bothersome. Sure, I can deliver a batch file along with everything, but most people and companies are expecting an .exe.

EDIT: Even if they have a JRE installed won't their system classpath need to be updated in order to use the java -jar comand from a batch file?
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Brian Legg wrote:Even if they have a JRE installed won't their system classpath need to be updated in order to use the java -jar comand from a batch file?


No, the batch file can set any temporary classpath it needs to. No need to alter the system classpath permanently.
 
Brian Legg
Ranch Hand
Posts: 488
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
True. Ok, thanks all!
 
reply
    Bookmark Topic Watch Topic
  • New Topic