Thread: g

    #1
  1. Rut row Raggy!
    Devshed Novice (500 - 999 posts)

    Join Date
    Jul 2001
    Location
    Tornado Alley
    Posts
    560
    Rep Power
    31

    Question 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 10:52 PM.
    Matt
  2. #2
  3. No Profile Picture
    Clueless llama
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Feb 2001
    Location
    Lincoln, NE. USA
    Posts
    2,353
    Rep Power
    117
    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:
    Code:
    Main-Class: package/className
    in your jars manifest file it will run when a user double clicks on it.
  4. #3
  5. Rut row Raggy!
    Devshed Novice (500 - 999 posts)

    Join Date
    Jul 2001
    Location
    Tornado Alley
    Posts
    560
    Rep Power
    31
    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!
    Matt
  6. #4
  7. No Profile Picture
    Clueless llama
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Feb 2001
    Location
    Lincoln, NE. USA
    Posts
    2,353
    Rep Power
    117
    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 10:33 PM.
  8. #5
  9. Rut row Raggy!
    Devshed Novice (500 - 999 posts)

    Join Date
    Jul 2001
    Location
    Tornado Alley
    Posts
    560
    Rep Power
    31
    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 06:18 AM.
    Matt
  10. #6
  11. No Profile Picture
    Clueless llama
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Feb 2001
    Location
    Lincoln, NE. USA
    Posts
    2,353
    Rep Power
    117
    Originally posted by Nemi
    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:
    Code:
    Main-Class: package/className
    in your jars manifest file it will run when a user double clicks on it.
    You need to edit the manifest. It is in the tutorial on jars I linked for you. :/
  12. #7
  13. Rut row Raggy!
    Devshed Novice (500 - 999 posts)

    Join Date
    Jul 2001
    Location
    Tornado Alley
    Posts
    560
    Rep Power
    31
    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?
    Matt
  14. #8
  15. No Profile Picture
    Clueless llama
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Feb 2001
    Location
    Lincoln, NE. USA
    Posts
    2,353
    Rep Power
    117
    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.
  16. #9
  17. Rut row Raggy!
    Devshed Novice (500 - 999 posts)

    Join Date
    Jul 2001
    Location
    Tornado Alley
    Posts
    560
    Rep Power
    31
    Originally posted by Nemi
    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.
    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 03:33 PM.
    Matt
  18. #10
  19. No Profile Picture
    Clueless llama
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Feb 2001
    Location
    Lincoln, NE. USA
    Posts
    2,353
    Rep Power
    117
    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:
    Originally posted by Marron79
    Do I just open .jar in a text editor and insert it in the top?
    When I had already stated:
    Originally posted by Nemi
    Jar files are simply a zip file with a different extension, so they can be opened using a zip program like winzip.
    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.

    You said:
    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).
    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.
    http://forums.devshed.com/t24097/sed...4d6ad7720.html
    Last edited by Nemi; February 19th, 2003 at 09:06 PM.
  20. #11
  21. Rut row Raggy!
    Devshed Novice (500 - 999 posts)

    Join Date
    Jul 2001
    Location
    Tornado Alley
    Posts
    560
    Rep Power
    31
    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.
    Matt
  22. #12
  23. No Profile Picture
    Clueless llama
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Feb 2001
    Location
    Lincoln, NE. USA
    Posts
    2,353
    Rep Power
    117
    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 04:06 PM.
  24. #13
  25. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Location
    Right Coast
    Posts
    25
    Rep Power
    0

    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):

    Main-Class: nameofclasswithmaininit

    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:

    javac CoolJavaProg.java

    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.

    J

IMN logo majestic logo threadwatch logo seochat tools logo