February 15th, 2003, 07:58 PM
Distributing java applications
Okay, so I've made a really simple java program. How do I distribute it to my non-programming friends to show off my new talents? All I know how to do so far is execute the program in DOS. Obviously, I do NOT want to distribute my code to others, so I'm hoping I can make an .exe file or something simple like that. I've searche extensivly on the java.sun.com website, as well as Yahoo, but nothing I couldn't find anything about deploying applications to others.
Last edited by marron79; February 15th, 2003 at 09:52 PM.
February 17th, 2003, 01:51 PM
I believe if your friends install the latest JRE 1.4.1 it will register the .jar file type to open with javaw.exe. If you then include the line:
in your jars manifest file it will run when a user double clicks on it.
February 17th, 2003, 08:46 PM
Okay, so how to I make jar files and where do my users download the JRE? I tried a few programs that made jar files, but I couldn't get them to work using Java Start Web (is that the same thing as JRE?). Also, can my users view my code by looking at the jar file or is the code compiled (like a .exe file)? Thanks!
February 17th, 2003, 09:30 PM
The way I mentioned was not using web start. I have not used web start myself. If you simply want to package an application like an exe and have a user run it, the simplest way is to package it in a jar file and set the manifest as I have said. You can read a jar tutorial here.
Users can get the Java Runtime Environment (JRE) from http://java.sun.com/getjava/
If you just package the class files the users cannot 'see' the code, though they can decompile it. If you want to keep someone from decompiling it you need to use an "obfuscator". Do a search on google for one if you are interested. If you DO want your users to see the code, you can include the .java files in the jar file along with the class files and they can then look at the ssource code. Jar files are simply a zip file with a different extension, so they can be opened using a zip program like winzip.
Last edited by Nemi; February 17th, 2003 at 09:33 PM.
February 18th, 2003, 04:29 AM
I downloaded Sun One Studio 4 CE and was able to make a jar file. However it won't open when I click on it. According to the Java website, I have the latest version of JRE. Do I need to do anything else after making the jar file to make it work?
Last edited by marron79; February 18th, 2003 at 05:18 AM.
February 18th, 2003, 03:55 PM
You need to edit the manifest. It is in the tutorial on jars I linked for you. :/
February 18th, 2003, 04:28 PM
I made the jar file in Sun One, so how do I add that tag? Do I just open .jar in a text editor and insert it in the top?
February 19th, 2003, 09:16 AM
Sorry, but you need to put forth a little effort. I could be mean and just say "RTFM", but I won't. However, I have already told you the jar file is simply a zip file and can be opened with any zip utility AND I have refered you to the JAR tutorial more than once, which states how to create, view and update jar files AND explains about the manifest file contained in the jar and how to make a jar file "executable".
I am more than willing to spend my time helping ppl better understand programming in general and java in particular, but I need to see that you are trying to figure something out on your own.
February 19th, 2003, 02:27 PM
I have read the tutorials, but I still don't understand it (what it says to do doesn't work--the .jar file won't load). I post questions here when I don't understand something after reading about it in a tutorial/book/manual. If all I needed was the tutorials I would've seached the Java website, I'm not stupid. If I wanted a reply saying "read the f***ing manual," I'd e-mail the folks at Sun. I come here to get some help/advice from others who have gone through the same problems and might have some insight. But I guess some people think that even though this forum is for developers, everyone who asks a question is a moron until proven otherwise.
Last edited by marron79; February 19th, 2003 at 02:33 PM.
February 19th, 2003, 04:46 PM
I can tell by your posts that you are a fairly intelligent individual. That tutorial on jars is about as basic and thorough as you can get. Since you are clearly a capable individual that leads me to one conclusion - you did not read the whole tutorial. Add to that, that you ask questions that have already been answered leads me to believe you are not paying attention. You asked:
When I had already stated:
You can get mad and dismiss what I am saying, but I truly hope you take something out of this that helps you interact with others in the future. Honestly, it is a little insulting when I give you the answers and you still ask the same questions.
What did you do to make it work that it said to do? Tell me what the tutorial said to do that you have tried and we can go from there.
EDIT: I see you must be an experienced php developer if your title and number of posts mean anything. Therefore you must be familiar with this post from the php forum.
Last edited by Nemi; February 19th, 2003 at 08:06 PM.
February 21st, 2003, 05:23 PM
Sorry for getting mad. I get pretty steamed when people here tell me to read the tutorial/manual/etc. To me, it's like saying "I don't want to help you." Obviously, I don't have a clue what I'm doing, which is why I repeated questions.
I've decided to put Java on hold for now and learn Windows programming using Win32/MFC and C/C++ from the ground up, since it's something I know many have used to make desktop programs. I have to take a Java class for my degree anyway, so hopefully after taking that class, I'll have some place to start with and be able to ask better questions and understand the advice given here. That's the way it was in the PHP forums. I used my PHP books to make the scripts for my website and only posted in the PHP forum when everything I could think of wouldn't work. IOW, I had something to show and I generally understood what was going on. In Java, I don't have a clue. Again, I apologize for getting frustrated and I sincerely appreciate your time and effort.
February 22nd, 2003, 03:04 PM
IMO, the languages are pretty well defined in their area of stengths. C++ is the way to go if you are interested in making client applications, though java is getting stronger in the gui area. PHP is great for small to medium web apps. Java is strong in the server/enterprise area (e.g., Large distributed web apps).
I learned C first. Then VB, Java, php and JSP/servlets. C/C++ is a great language to know. But the real value with C++ is in knowing win32/MFC. That is where employers are looking for experience in if you are making client applications. I do not know MFC so I have made a few client apps in Java, but I can say that the best client apps are still written using C++. Java, like linux, has made huge leaps and bounds into the desktop environment, but it will still be a little time before it works as well as C++/Windows. Hopefully in another year or two.
EDIT: I also see you are from Omaha. What a coincidence. ttyl
Last edited by Nemi; February 22nd, 2003 at 03:06 PM.
February 23rd, 2003, 04:27 AM
here are the steps
This is all from the command line
1) javac yoursourcefiles.java
2) notepad manifest.txt
In this step include the following line followed by a cr/lf (hit your <ENTER> key):
obviosly you should change the above to the actual name of your class (WITHOUT the .class ending)
3) jar cvfm NameOfYourJarFile.jar manifest.txt ClassFiles.class
now, you need to substitute NameOfYourJarFile.jar with what yours should be called. Also, ClassFiles.class is meant to represent the class(es) you are using.
Here is an example:
jar cvfm CoolJavaJar.jar manifest.txt CoolJavaProg.class
4) java -jar CoolJavaJar.jar
This "runs" the program... or you could double click it.
note: any console-only program won't even appear using the double-click method.