How do you change a java program to a single file executable file?

Hey guys I'm back with another new to java question :)
i would like to have my java program that i made into an executable single file,
i currently have my project compressed into a JAR file,
and its working fine when i go click on it in the file that its in, it works fine but it has to be in that file to work... :(, i was wondering is there a way that i can have that file on its own to work, so that i can send it to someone and they just have to have that one file.
thanks for the help

If you want a jar file to behave the same way no matter what directory it is in (or is run from) then you have to make sure that all resources it uses are included in the jar. Such resources could include images and sounds that the application uses. Or files that it references.
For instance thisFile foo = new File("foo.txt");is going to name a file that it is in the current directory (the directory the jarred or unjarred application was run from). If you move the jar, but don't move foo.txt then it won't be able to find the file.
Any of your code that directly or indirectly uses files will have to change to use resources within the jar archive instead.
If you get stuck, post some code. Something brief, compilable, runnable which shows what you mean by saying that it doesn't work.

Similar Messages

  • How do you change default java logo in JOptionPane?

    I want to know how do you change the icon(the java logo in the title bar) for the JOptionPane box. I am using a swing interface. I can change the icon of the main frame but not of the JOptionPane.
    for the main frame i have used:
         Toolkit kit = Toolkit.getDefaultToolkit();
         Image img = kit.getImage("mypicture.gif");
         setIconImage(img);
    Toolkit is part of java.awt package.
    thanks

    here was a discussions about that
    http://forum.java.sun.com/thread.jsp?thread=120724&forum=57&message=316526

  • How can you get a java program working on a cell phone?

    I was thinking of making some stuff for cell phones so i was wondering how you get a normal java program to work on cells.

    its all j2me - midlet package....Huh? The jsr-118 MID profile alone has 11 packages, one of which is javax.microedition.midlet. Notj2me - midlet.
    works best on nokia phones.Sez who? You seem to be confusing Java ME with Symbian C.
    you can use net beans midlet packge add-on.Only it's called the NetBeans Mobiliity Pack.
    Its easy to use and has lots of tutorials.Ditto for the Wireless toolkit for CLDC.
    just search on google.Yes, but with which keywords?
    @OP:
    NetBeans mobility pack comes with a short tutorial and several samples, you also need to download the latest WTK as the ver. 2.2 which comes bundled with NetBeans is just too buggy to work with. Then there are the manufacturer-specific SDKs from Nokia, Motorola, Sony Ericsson and (maybe) others.
    If and when you get started in Java ME aka j2me, it will be appropriate to post any questions you might have on the mobility forums, not here.
    Google "j2me tutorial" for many good hits.
    luck, db

  • URGENT: How do you distribute a Java program??

    I've made a small program using Java and it turned out to work perfectly fine, but now I am wondering how to package it so that anyone can just double-click something and have it run. I tried packaging it into a Jar file, but nothing seems to work (i.e. I get some manifest error) I've looked at tutorials online and I've also used the Jar packager tool that is a part of the JCreator IDE.
    I was also thinking about writing a dos batch file to have the program run from the command line; would that work as well??
    What is the easiest /nicest way to have a Java program packaged?(Sun should really add a java/.class to *.exe converter in a future JDK...)

    So many research-challenged people, and so little time.
    Google for "Java EXE"
    And no, Sun should NOT provide EXE output. EXEcutables are for a specific platform. Bytecode (.class files) are for platform independence, so that you CAN distribute the bytecode to run on any platform (any platform with a Java runtime, that is).

  • How do you start a java program with more RAM alloaction

    Hi
    can anyone please tell me how to start a java program to start with lots of RAM (RAM size is sent as a parameter), I have seen it somewhere and now I cant remember it. I have a server application to run this way.
    thanks and rgds
    sunil

    see the tooldocs of java: http://java.sun.com/j2se/1.4/docs/tooldocs/tools.html

  • How do I change the default program that opens .acsm files?

    I am borrowing library eBooks to read on my Sony Reader.  I want to ensure that Adobe Digital Editions is the default program to open .acsm files, but am not sure how to do that.  Thanks for the help!

    Right (control) click on the .acsm file > select Open With > then select Adobe Digital Editions.
    Likewise you can select all of files in a folder with Edit > Select All > then Get Info and set them all to Open with: Adobe Digital Editions or whatever.
    Dennis

  • How do you change a color on an imported tif file in adobe illustrator?

    Hi, I have put together an illustrator file by importing various tiffs and putting them togetherfor a figure in a scientfic journal.  I have to change the red in all my images to magenta for those that are colorblind.  I was hoping someone could help me figure out how i can change red to magenta in illustrator off of imported tiff files (not objects that were created in illustrator - i know how to do that).  I have tried to get the answer from technical support over the phone but they keep disconnecting me?  Can anyone help?

    Thanks for the input.  I do know how to do it in photopshop and am trying to export my files into layered .psd-s but the layers don't always export perfectly and the journal needs me to send a layered file (doesn't matter .ai or .psd).  The figure should have been put together in photoshop originally, but unfortunately it wasn't.  The Phantam CS seems interesting but you alos have to buy it and I don't want to have to purchase something to do it.  Especially since Adobe says there is a way to do it.  Just don't know what that way is....

  • How do you change the resolution size of a mp4 file?

    I am looking for a free (really free, not just a trial for 30 days free) program that will allow me to change the resolution of a mp4 video.
    If this is a "parameter" setting issue in DW what would be the parameter and the value?
    The video is here: http://www.argraph.com/Sirui-P-Series-Monopods.html#psSeries.............a little past midway down the page.
    As you see the words SIRUI and the tag line cannot be seen in their entirety.
    THIS is the way it should look.....
    The second image represents a youtube link but my boss said he cannot see it on his laptop or tablet
    and insists that I use mp4 because it works with all formats; iphone, android, pc and mac.
    I tried doubling the size of the file and it worked but was SOoooooo big that it blew the page out so I suspect that I
    have to resize the file.
    Ken? Nancy? ANYBODY?????   Seriously as always any suggestion would be greatly appreciated.
    -Gwynnplaine-

    1. As far as HTML5 support, if they have a browser made within the last few years (I think since about 2009), it supports html5. The page I linked to gives the versions where all of the major browsers started supporting the <video> tag.
    2. The "your browser does not support..." text is what appears on screen when a viewer uses a browser that doesn't support HTML5 (like IE8).
    If you still plan to support the old non-html5 browsers, the best thing to do is to place a fallback video using the old <object><embed> method in that "your browser does not support" location. That way, if they don't have an html5 compatible browser, the fallback video will play using whatever plug-in they have installed to deal with it. It would look like this...
    <video width="320" height="240" controls>
    <source src="movie.mp4" type="video/mp4" />
    <source src="movie.ogg" type="video/ogg" />
    <object width="320" height="240">
    <param name="movie" value="myvideo.swf" />
    <embed src="movie.swf" width="320" height="240"></embed>
    </object>
    </video>

  • How can I change the default program to open Pages files in Finder from Pages 5.0 to Pages '09?

    I’ve tried. It seems Mavericks can’t tell the difference between the programs or won’t let me.
    Message was edited by: WWGreaves

    Open DIsk Utility and in the toolbar select Disk Image. The file selector will open and you'll have to do three things: 1) just as with any file, name it and point the file selector to where you want it to be saved, 2) near the bottom you'll see name - type iWork 2013 and 3) below that select the image size. Click on size, choose custom and type 1500 MB then click on the Create button.
    Some time will pass and then you'll see an external disk pop up on your desktop and/or the Finder window sidebar. Drag the three programs into it and eject it like any other external disk. Now delete the programs from your applications window.
    Where ever it was you pointed the file selector to you'll see the file you created. Double click on it and the disk image will mount again.

  • Change the java program in *.exe

    how can i do to change my java program in a .exe file ? This could be useful if the user doesn't have the java runtime environment.

    Hello
    You can use third party softwares like
    PJ2Exe or sumthing like that
    search on google
    Rohan

  • How do you change default program?

    I have photoshop on an external drive which is fine... But it is listed as the default program to open jpeg files, and I am often not connected to the external, when I'm on the go.
    How do I change the default program back to Preview?

    Yes it does list Preview as default, when the ext is not connected, but once the external is connected Photoshop takes over. I unfortunately can't do anything more about this at the moment as the External decided to stop working.
    I've already posted this error on the Western Digital website, but maybe I can get feedback her as well... My 500Gb WD My Book, worked fine for months now, yesterday I started it up and it would not access it, when i went into drive utility it is not listed as a 2 Tb WD Esternal. **** it grew!?! Same thing when connected to a PC, connection established, but you cant see the drive in Explorer. Weird...?

  • How do you change the language to English in Photoshop CS5 after installation is completed? When I installed the program, English was not one of the language options so now everything reads in spanish. I can not read in spanish. Please help!!

    How do you change the language to English in Photoshop CS5 after installation is completed? When I installed the program, English was not one of the language options so now everything reads in spanish. I can not read in spanish. Please help!!

    Hi mujabee1111,
    Please uninstall the application from your machine and then use the link below to download the installer for the CS5 download in English language:
    Download CS5 products
    Regards,
    Sheena

  • How do you change what programs open on starting up?

    How do you change what programs open on start up?

    By changing the list of login items for your user account in System Preferences, and if Lion is automatically reopening applications, which ones are running when the computer is shut down.
    (64981)

  • How can I use a Java program to write an executable Applescript

    I'm using a PC with Windows XP. I'm a private developer. I've written a project in Java and wish to deploy it to other people using email. I've written an Install program (the Main-Class) and successfully packed this in a jar file with the project class files and some data files all as described in the deployment trail in the Java Tutorials. A recipient with a Mac with OS X downloads the jar file and runs it to install the project class files and some data files. The install program then writes an Applescript file (Vocab.scpt shown below) on the Desktop to make starting my downloaded program easier but it doesn't seem to work and I think it may be because the script file is not "executable". Could this be the case? If so, how could I change my install program to make the script file executable or alternatively use some other system to start the downloaded program?
    Vocab.scpt:-
    # Script to start: Vocab Version: 1.0.0
    do shell script "cd /Applications/Vocab; Java Vocab"
    Many thanks for your interest. Unfortunately I don't have a Mac to experiment with this problem and although I have spent some days on and off trying to find an answer in the mass of information available on Apple's website I can only find small clues here and there to answer my problem (which I would have thought was quite a common one). In Windows a batch file (eg. Vocab.bat) is automatically executable.

    I didn't expect you to have your customer run the command. I would expect you to create the executable and install it. However, there wouldn't be any difference in what you are creating and the .jar file. Either way it is a faceless icon. For that matter, it is no different than a batch file on Windows. I'm not sure what they wouldn't understand with, "copy the Vocab.jar file to wherever you want and double-click it to run the program." In addition, you probably ought to point out that Java is not installed on Mac OS X Lion (10.7.x) and when they double-click the jar file (or whatever you send them), the system will ask if they want to install Java.
    What you really need to do is package up the app inside a Mac application package and provide the user with the application on a .dmg (disk image). Take a look here: http://developer.apple.com/library/mac/#documentation/Java/Conceptual/Jar_Bundle r/Introduction/Introduction.html#//apple_ref/doc/uid/TP40000884
    I also found this which uses ANT to create the bundle: http://informagen.com/JarBundler/

  • How to interchange data between Java Program and C++ Program

    I constructed a java program using netbeans IDE that has ability to connect with a respective DLL; I want to connect and interchange data between my java program(.jar) and VSC++ program(.exe) through DLLs.JNI uses single Dll to invoke C/C++ function in native manner,In order to increase the efficiency I tried to connect and interchange primitive data types between Java program and C++ program using that DLL(JNI implemented).
    Unfortunately C++ program cannot obtain data values that has been changed by Java Program.For example - If I declare a global int variable in DLL,java program can catch that int variable and can update it but If I run my C++ program(exe) loading same DLL simultaneously it cannot receive the updated value of that int variable declared in the DLL.
    Therefore I need a solution to share/Interchange at least primitive data and their respective values between a JAVA and C++ Program using JNI (in spite of date transferring through Sockets).JAVA TO C/C++ & C/C++ to JAVA using DLLs.
    (TWO WAY COMMUNICATION)
    JAVA.jar  <=> <JNI> <=> DLL <=> [Connector Program C/C++] <=> C/C++ .exe
    PLEASE HELP ME!! THANK YOU

    What in the are you trying to say? What does "filled into the servlet mean?" Is the map somewhere outside the servlet? In a different process? Are you asking how to extract data from a map? Something else?
    Sorry, but your question makes no sense.

Maybe you are looking for

  • Parallel process run independently, but do not stop when vi completes

    So I posted a problem yesterday about getting 'elapsed time' express vi to provide updates from a sub-vi to the calling vi. It was suggested that I create a parallel process in the sub-vi that will run the elapsed time function at the same time the o

  • How can I import photos from a Nikon P520 into I photo 11

    I have previously hooked the camera up to a powered USB , turned the camera on and it opened I photo 11.  I was able to import and edit the photos in I photo.  I tried this process now and I do not get I photo to open, the camera does not appear in t

  • Java applet cache parameter

    I'm sorry if that what I'm looking for is described elsewhere. I couldn't find it. I seem to have a bug with the latest Apple's java implementation (1.5) downloaded with the latest Software Update. I have to switch off applet caching for a certain ap

  • No signal .. No help

    Hi people.I started off by being frustrated.  Now i'm fuming.Can anyone here help?  Sorry if this is long. Thanks. I was very loyal to One2One/TMobile for over 20 years - was really happy with them.Over the last 2 years, the signal became intermitten

  • Where do I find my second purchased download?

    I bought Photoshop digitally and would like to use my second download for my new computer but I don't know where to redeem it. Any suggestions?