Question: I want to build a runnable jar in java. I need to include some of the files in the jar so that when I execute jar the files are automatically read from the java class. Hence I created a folder in the project and referred these files from the project. I created jar file following some tutorial but I could not able to include these external files in my jar file. Please let me about creating runnable jar with external files.

My file struture is

```
Test
|
|
-------src
|        |
|        default package
|                      |
|                      |
|                      test1.java
|
 -------FileFOlder
|              |
|              | 
|              abc.txt

```

I am accessing **abc.txt** in **test1.java** class. 
My code is, 

```
public class test1 {

public static void main(String[] args) throws IOException {

    char [] read = new char[20];
    String path = new File(".").getCanonicalPath();
    path = path+"\\Newfolder\\abc.txt";
    System.out.println(path);
    File nF = new File(path);
    FileReader fR = new FileReader(nF);
    fR.read(read);
    for(char c : read){
        System.out.print(c);
    }
    fR.close();
    System.out.println(" Hi..This is test program ");
}

}

```

When I create executable jar using eclipse export option, I am unable to see FileFolder directory inside the jar. Please give me some information regarding this.

Answer: 
The answer was already on this site.
[How to rename duplicates in list using LINQ](https://stackoverflow.com/questions/7163467/how-to-rename-duplicates-in-list-using-linq)

Code is:

```
      IEnumerable<String> GetUnique(IEnumerable<String> list)
    {
        HashSet<String> itms = new HashSet<String>();
        foreach(string itm in list)
        {
            string itr = itm;
            while(itms.Contains(itr))
            {
                itr = itr + "_";
            }
            itms.Add(itr);
            yield return itr;
        }
    }   

```
Since Dictionary won't allow for duplicate entries (it throws an ArgumentException was unhandled exception), thus handling the "heavy lifting" of ensuring uniqueness and sequence order (still testing that one). I think I'm using GSI.Sequence wrong because there could be multiple sequences for receipe items. (This is NOT the answer, but a place I could put code. I hope I did it right) Hat tip to <http://williablog.net/williablog/post/2011/08/30/Generic-AddOrUpdate-Extension-for-IDictionary.aspx>

```
      while(reader.Read())
     {
                    RecipeItems GSI = new RecipeItems();
                    GSI.RecipeItem = reader[0].ToString();
                    GSI.Sequence = Convert.ToInt32(reader[1].ToString());
                    GSI.RecipeName = reader[2].ToString();
                    GSI.MaxSequence = Convert.ToInt32(reader[3].ToString());

                    if (dictionary.ContainsKey(GSI.RecipeItem))
                    {
                          dictionary.[GSI.RecipeItem] = GSI.Sequence);
                    }
                    else
                    {    
                        dictionary.Add(GSI.RecipeItem, GSI.Sequence);
                    }

    } 

```

I think the final answer here ended up being something that I didn't necessarily foresee or desire. With approximately 94 unique items, you will end up with a list of about 428 unique recipe items over the course of 20 recipes. This would give me a list where I could have the appropriate recipe item in the right sequence. I still think my logic on this one is BAD, but it makes sense when you figure you have a couple of recipe items per recipe out of order and must be duplicated and than you multiply that times the number of recipes.