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

    Default Writing to text file using an executable Jar

    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
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Rep Power

    Default Re: Writing to text file using an executable Jar

    Quote Originally Posted by frodo5654 View Post
    the jar file won't create/write to a text file.
    So what does it do instead? Do you get any error messages?

Similar Threads

  1. Replies: 8
    Last Post: 07-17-2011, 02:38 PM
  2. Writing Text To A File
    By loopsnhoops in forum New To Java
    Replies: 15
    Last Post: 06-01-2011, 03:27 AM
  3. Writing into a text file
    By africanhacker in forum New To Java
    Replies: 3
    Last Post: 03-31-2011, 10:44 PM
  4. Replies: 1
    Last Post: 02-27-2010, 01:29 AM
  5. writing text to file
    By notwist in forum New To Java
    Replies: 3
    Last Post: 04-25-2008, 04:20 AM

Tags for this Thread

Posting Permissions

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