Click here to Skip to main content
15,920,217 members
Home / Discussions / Java
   

Java

 
AnswerRe: GPS Pin
Richard MacCutchan2-Jan-12 22:13
mveRichard MacCutchan2-Jan-12 22:13 
GeneralRe: GPS Pin
Nagy Vilmos3-Jan-12 9:04
professionalNagy Vilmos3-Jan-12 9:04 
GeneralRe: GPS Pin
Richard MacCutchan3-Jan-12 22:30
mveRichard MacCutchan3-Jan-12 22:30 
AnswerRe: GPS Pin
TorstenH.8-Jan-12 22:20
TorstenH.8-Jan-12 22:20 
QuestionHijriCalendar Pin
Rebin Abdullah31-Dec-11 2:15
Rebin Abdullah31-Dec-11 2:15 
AnswerRe: HijriCalendar Pin
Richard MacCutchan31-Dec-11 2:48
mveRichard MacCutchan31-Dec-11 2:48 
AnswerRe: HijriCalendar Pin
RaviRanjanKr31-Dec-11 3:06
professionalRaviRanjanKr31-Dec-11 3:06 
QuestionMedia folder problem in Jar file Pin
loctrice29-Dec-11 16:56
professionalloctrice29-Dec-11 16:56 
I have begun work on a 2d game. Everything was going as planned in netbeans, until I tried to make the .jar for a friend to view my progress. I am getting a URI is not hierarchial exception.

My issue is , for a game object, I am using a folder structure to keep sprite strips rather than having one large sprite. This results in :

Media/
CharacterName/
AnimationName/
image.extension

the programming object just holds it's folder as a string, and I pass the getResource() URL to an object to fill the map of images. My error comes from this code:

Java
dir = new File(s.toURI());


I take the directory, and call listFiles and pass the file names found to the sprite loader. Here is a code snippet:

Java
dir = new File(s.toURI());
 File[] chld = dir.listFiles();
        //get a list of files in the image/character folder
        for(File f:chld)
        {
            //get a list of the files for each dir
            File[] grandChild = f.listFiles();
            for(File t:grandChild)
            {
                 String fname = t.getAbsolutePath();
                 System.out.println(fname);
                 String temp = fname;
                 temp = temp.substring(temp.lastIndexOf("/") + 1,temp.lastIndexOf("."));
                 String animName = temp.replaceAll("\\d*$", "");
                 int numPics = 0;
                 Pattern p = Pattern.compile("[0-9]+");
                 Matcher m = p.matcher(temp);
                 while(m.find()){
                     numPics = Integer.parseInt(m.group());
                 }
                 System.out.println("animation name: " + animName);
                 System.out.println("file name: " + fname);
                 System.out.println("number of pictures: " + numPics);
                Animations.put(animName, sl.loadStripImageArray(fname, numPics));
            }
        }


Excuse the poor code for now, I'm still working on it. (like the variable named t).

sl is the sprite loader, and Animations is a hash map. This works fine until I package the project. I don't want to write a bunch of convoluted code that I have to switch back and forth between netbeans and the jar. I'd like to have something that "just works".

I have considered application data, and I can do that if necessary. I'd like it to work as a package if possible though, and not have to deal with external folders.
AnswerRe: Media folder problem in Jar file Pin
loctrice30-Dec-11 7:06
professionalloctrice30-Dec-11 7:06 
AnswerRe: Media folder problem in Jar file Pin
jschell30-Dec-11 8:51
jschell30-Dec-11 8:51 
GeneralRe: Media folder problem in Jar file Pin
loctrice30-Dec-11 9:06
professionalloctrice30-Dec-11 9:06 
GeneralRe: Media folder problem in Jar file Pin
jschell31-Dec-11 13:29
jschell31-Dec-11 13:29 
GeneralRe: Media folder problem in Jar file Pin
loctrice1-Jan-12 4:29
professionalloctrice1-Jan-12 4:29 
GeneralRe: Media folder problem in Jar file Pin
jschell2-Jan-12 10:39
jschell2-Jan-12 10:39 
GeneralRe: Media folder problem in Jar file Pin
loctrice3-Jan-12 7:36
professionalloctrice3-Jan-12 7:36 
GeneralRe: Media folder problem in Jar file Pin
jschell3-Jan-12 8:33
jschell3-Jan-12 8:33 
GeneralRe: Media folder problem in Jar file Pin
loctrice3-Jan-12 9:30
professionalloctrice3-Jan-12 9:30 
GeneralRe: Media folder problem in Jar file Pin
jschell3-Jan-12 10:36
jschell3-Jan-12 10:36 
GeneralRe: Media folder problem in Jar file Pin
loctrice3-Jan-12 11:00
professionalloctrice3-Jan-12 11:00 
QuestionUnOrdered SET Pin
saadullah Bhutto21-Dec-11 4:39
saadullah Bhutto21-Dec-11 4:39 
AnswerRe: UnOrdered SET Pin
Luc Pattyn21-Dec-11 5:21
sitebuilderLuc Pattyn21-Dec-11 5:21 
AnswerRe: UnOrdered SET Pin
TorstenH.21-Dec-11 20:50
TorstenH.21-Dec-11 20:50 
AnswerRe: UnOrdered SET Pin
jschell26-Dec-11 8:54
jschell26-Dec-11 8:54 
AnswerRe: UnOrdered SET Pin
bennis9827-Dec-11 15:21
bennis9827-Dec-11 15:21 
Questionjava.lang.ClassNotFoundException Pin
arthur89kim18-Dec-11 16:44
arthur89kim18-Dec-11 16:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.