Results 1 to 2 of 2
  1. #1
    frodo5654 is offline Member
    Join Date
    Nov 2011
    Rep Power

    Default Jar file writing

    Hey guys I'm new here so sorry if this is supposed to be put somewhere else, but...
    My friend and i have been trying to take a simple program of ours and make it an executable jar file so we can run it on multiple computers(obviously). The problem we have been having is whenever we export our program into a jar(via Eclipse) the jar file won't create/write to a text file. When I run the program normally through Eclipse and not the jar, it creates the text file and writes to it just fine so was wondering if i was doing something wrong...
    Java Code:
    public class Main {
        public static void main(String[] args)
            File file1 = new File(System.getProperty("user.home") + "\\Desktop\\Groups.txt");
            String[] students = new String[]{"Hurley", "Trad", "Kelsey", "Colangelo", "Curry", "Bolton", "Horine", "Ruth", "Cardona", "Bacelli", "Bosko", "Brannon", "Delacruz", "Furlow", "Harden", "Humes", "Kolos", "Long", "Lowman", "Lundstrom", "Oliver", "Race", "Rodriguez", "Stokes", "Weld", "Windham"};
            int j = 1;
            try {
                BufferedWriter out = new BufferedWriter(new FileWriter(file1));
                for (int i = 0; i<26; i+=2)
            }catch (IOException e){
        public static void exch(String[] a, int i, int j) {
            String swap = a[i];
            a[i] = a[j];
            a[j] = swap;
        public static void shuffle(String[] a) {
            int N = a.length;
            for (int i = 0; i < N; i++) {
                int r = i + (int) (Math.random() * (N-i));   // between i and N-1
                exch(a, i, r);
    And before anyone says anything about the retarded shuffle^^ i didn't write this my buddy knows nothing about Collections.shuffle(ArrayList) XD

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    On vacation
    Rep Power

    Default Re: Jar file writing

    What happens when you double click on your jar file?
    I assume that you want your program to start executing when you double click on the jar file.

    To get any error messages the program generates, open a command prompt window, change to the directory containing the jar file and enter the command:
    java -jar <YOURJARFILENAME>.jar

    Copy and paste the console contents here.
    To copy the contents of the command prompt window:
    Click on Icon in upper left corner
    Select Edit
    Select 'Select All' - The selection will show
    Click in upper left again
    Select Edit and click 'Copy'

    Paste here.

Similar Threads

  1. Replies: 14
    Last Post: 07-15-2011, 05:22 AM
  2. Replies: 1
    Last Post: 02-27-2010, 02:29 AM
  3. Replies: 9
    Last Post: 10-20-2009, 10:52 AM
  4. Replies: 3
    Last Post: 05-09-2009, 11:31 PM
  5. Replies: 9
    Last Post: 07-10-2008, 04:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts