Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Telamon

[java] Distributing Java Programs

This topic is 5490 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I took a class on Java last year and am using it at my job at IBM, but I have a really basic question that I''m ashamed not to know the answer for. If I had a Java app I wanted to distribute to people, without giving them the source, how would I package it? In MSVC or .NET I would just compile the sucker to an .exe, zip it up, and upload it to my website. I''ve poked around on the net for a while and decided I''m not looking for a way to compile Java to a native .exe (since then I''d lose cross platformness). So I want to package my code into some kind of self-executing, IDE-free, neat little app with a program icon. Is this what .JAR files are? Limewire is written in Java, but works like this. It''s frustrating that the answer to this problem isn''t self-evident. It might be because I''m using IBM''s WebSphere Studio, whose UI is so backward, unintuitive, and primative compared to the .Net GUI, which is what I''m used to. Thanks! ---------------------------------------- Let be be finale of seem, seems to me. ---------------------------------------- Coding: http://www.stanford.edu/~jjshed/coding Miscellany: http://www.stanford.edu/~jjshed

Share this post


Link to post
Share on other sites
Advertisement
If I understood correctly, you should use a JAR file (which combines many things such as class files and resources like images) into one file, and there's a way to configure the JAR file to launch a certian file in it. I don't belive a JAR file can have it's own icon though.
How to create a JAR file: http://www.javacoffeebreak.com/faq/faq0028.html
How to configure the manifest file to launch a certian class file: http://java.sun.com/docs/books/tutorial/jar/basics/mod.html

Also, just a quick note on the not distributing the source with it, just in case you didn't know, there are java decompilers which would be able to get the source, so you should use an obfuscator (sp?), that way if they decompile it, (and i speak from experience) it's very hard to understand what the program does.

Hope this helps, good luck on your project!

[edited by - Kajsngweaaweg on July 8, 2003 2:31:39 PM]

Share this post


Link to post
Share on other sites
A word to the wise on jar files. Depending on that kind of resources that are going to be included in the project, there might be changes you will need to make to your code to get the stuff out of the jar file. Not anything hard, but just know there could be differences. I put a little application in a jar file for class, along with the image files I was using, but I had to completle change the code when I made it an applet, because of the security issues of trying to get stuff from the jar file while in the applet. I did not work like the regular code where the *.jpg files were just in the same folder. And know that a jar file is just java''s zip file. You can open a jar file with winzip and see everything inside. It is not like an executable.

I think, therfore I am.
I think?

Share this post


Link to post
Share on other sites
Ick. None of that sounds too great. How to serious businesses sell their Java-based products if anyone can just open up their JARs and rifle through all their resources? What is the professional solution to this problem?

Share this post


Link to post
Share on other sites
This may seem like a strange question, and I don''t mean to insult you. But, if you work at IBM, wouldn''t you have access to whatever they used to distribute Java applications? I know IBM has some Java-based products already (i.e. Websphere).

However, if you''re looking for something to distribute non-commercially or just for free, you could try exeJ or exe4j. I tried exe4j, but couldn''t get it to work correctly, however, I''m sure others have.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Many applications, written in C/C++, are distributed with an installer exe. Why not do it in Java? It´s possible. For example, you could download a free version of the very good program InstallAnywhere:

http://www.zerog.com/

Regards
Johan

Share this post


Link to post
Share on other sites
My understanding is that the .class file IS pre-compiled. Unless somebody has a byte-code decompiler, they can''t read your source if you distrubute the class file. The same danger exists in C++/.net with Machine-Language to ASM decompilers, though I bet byte-codes are less cryptic.

As far as a self-executing java program, I know that windows doesn''t support java natively (unlike linux, ect) so you''d need to package your .class with a JVM, or a byte-code interpreter. If somebody wants to excecute your application under linux then they can just run it with javac. Could you distribute your code with a .bat file perhaps?

If your target platform is Windows, I can''t think of a simple way to go about it.

Share this post


Link to post
Share on other sites
Using a jar file is how professional software is distributed. Some use multiple jars. Some also make platform specific installers, but with the same jar files in the installers.

Some companies also convert to platform specific executables for increased execution speed.

If you want to use a jar, you can make it so the user only has to double-click(Windows) on it buy including the following line in the manifest file:

Main-class: YourMainClassFile.class





First make it work,
then make it fast.

--Brian Kernighan

"I’m happy to share what I can, because I’m in it for the love of programming. The Ferraris are just gravy, honest!" --John Carmack: Forward to Graphics Programming Black Book

Share this post


Link to post
Share on other sites
_Infinity, about the byte code decompiling, if you were refering to my post, I was just warning Telamon that if he was concerned about making sure nobody got the source, he should use a obfuscator because there are many Java byte code decompilers, and contrary to what many obfuscator programs boast, their program does not make it impossible to decompile the .class file, it simply makes it so when people do, it''s very hard to understand what it does (all variables are renamed to single letter names, same with methods, etc).

Share this post


Link to post
Share on other sites
quote:
Original post by Telamon
Ick. None of that sounds too great. How to serious businesses sell their Java-based products if anyone can just open up their JARs and rifle through all their resources? What is the professional solution to this problem?


easy. its called not using java. i have yet to see a serious and/or professional software product use java.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!