Help! Terminal won't run .jar file

Discussion in 'Mac Programming' started by aburtson, Dec 20, 2010.

  1. macrumors newbie

    Joined:
    Dec 20, 2010
    #1
    Hey everyone,

    I've been trying to work on an app for Android on my mac and I was using a tool inside the Android SDK called draw9patch, which lets me determine how an image will be stretched. I got it working before, but I must have done something wrong recently because my terminal won't let me run the file anymore. When I click on the draw9patch file, this is what the terminal comes up with:

    Last login: Mon Dec 20 12:57:40 on ttys000
    /android-sdk-mac_86/tools/draw9patch ; exit;
    BURTSON:~ theburt00$ /android-sdk-mac_86/tools/draw9patch ; exit;
    /android-sdk-mac_86/tools/draw9patch: line 30: dirname: command not found
    /android-sdk-mac_86/tools/draw9patch: line 33: basename: command not found
    /android-sdk-mac_86/tools/draw9patch: line 40: dirname: command not found
    /android-sdk-mac_86/tools/draw9patch: line 41: dirname: command not found
    /android-sdk-mac_86/tools/draw9patch: line 45: dirname: command not found
    /android-sdk-mac_86/tools/draw9patch: line 46: dirname: command not found
    /android-sdk-mac_86/tools/draw9patch: line 50: basename: command not found
    : can't find draw9patch.jar
    logout

    [Process completed]

    By the way, I placed the Android SDK folder at the root of my hard drive.

    Does anyone know what the problem is? Thanks in advance!
     
  2. LPZ, Dec 20, 2010
    Last edited: Dec 20, 2010

    LPZ
    macrumors 65816

    Joined:
    Jul 11, 2006
    #2
    What do you get from the following in Terminal:

    Code:
    echo $SHELL; echo $PATH; which dirname basename
     
  3. thread starter macrumors newbie

    Joined:
    Dec 20, 2010
    #3
    Here it is:

    Code:
    Last login: Mon Dec 20 13:13:46 on ttys000
    BURTSON:~ theburt00$ echo $SHELL; echo $PATH; which dirname basename
    /bin/bash
    {PATH}:/Users/theburt00/Documents/android-sdk-mac_86/tools
    -bash: which: command not found
    BURTSON:~ theburt00$ 
    
    Ah, I think the problem is because I've tried to run it in different locations. Looks like its referring to a file I put in Documents that I have since deleted.

    Do you know what I should do next? Thanks!
     
  4. macrumors 601

    talmy

    Joined:
    Oct 26, 2009
    Location:
    Oregon
    #4
    Your path looks messed up. That's why it can't find anything but shell commands. Probably a problem in your .profile file. You can temporarily restore sanity with:

    export PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"

    You probably want the statement:

    export PATH="/Users/theburt00/Documents/android-sdk-mac_86/tools:$PATH"

    in your .profile.
     
  5. thread starter macrumors newbie

    Joined:
    Dec 20, 2010
    #5
    What should I put in the terminal? Do I have to access the .profile somehow first? I'm new to the terminal, so I don't know what to do. The file I'm trying to open is under /android-sdk-mac_86/tools/draw9patch
     
  6. LPZ
    macrumors 65816

    Joined:
    Jul 11, 2006
    #6
    First let's get the PATH variable fixed, as Talmy suggested. In Terminal, enter

    Code:
    export PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"
    See if draw9patch then works as it did before.

    In any case, let's also see what your .profile looks like. In Terminal, please enter

    Code:
    cat ~/.profile
    and post the result.
     
  7. thread starter macrumors newbie

    Joined:
    Dec 20, 2010
    #7
    draw9patch still doesn't work.

    here's the latest output:

    Code:
    Last login: Mon Dec 20 18:39:53 on ttys000
    BURTSON:~ theburt00$ cat ~/.profile
    -bash: cat: command not found
    BURTSON:~ theburt00$ 
    
     
  8. macrumors 603

    Joined:
    Aug 9, 2009
    #8
    Your PATH is damaged, so what you tried can't work. An undamaged PATH is needed to find commands, including the 'cat' command. That's why the first instruction you were told to do was:
    If you did the above once, it only lasted until the Terminal window closed. If you didn't do the above at all, then you need to be more careful about following instructions.

    Until after you've fixed your .profile, you will need to paste this command into your Terminal window every time you start Terminal or open a new Terminal window:
    Code:
    export PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"
    
    I suggest copying and pasting the above command into a plain text file in TextEdit.app. You can then copy and paste it into Terminal windows as needed. And until you get your .profile fixed, you will probably need it more than once.
     
  9. thread starter macrumors newbie

    Joined:
    Dec 20, 2010
    #9
    ok i think im getting closer. i put that command in the terminal and then tried to open draw9patch. it caused the terminal to output something i havent seen before, but it still hasn't opened draw9patch. am i doing the right thing to open it? also, do you know a way i can fix my damaged path? thanks

    Code:
     Last login: Tue Dec 21 14:13:28 on ttys000
    BURTSON:~ theburt00$ export PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"
    BURTSON:~ theburt00$ /android-sdk-mac_86/tools/draw9patch
    Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/jdesktop/swingworker/SwingWorker
    	at com.android.draw9patch.Application$1.run(Application.java:48)
    	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
    	at java.awt.EventQueue.dispatchEvent(EventQueue.java:633)
    	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
    	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
    	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
    	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
    	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
    	at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
    Caused by: java.lang.ClassNotFoundException: org.jdesktop.swingworker.SwingWorker
    	at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    	at sun.misc.Launcher$ExtClassLoader.findClass(Launcher.java:229)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
    	... 9 more
    BURTSON:~ theburt00$ 
    
     
  10. LPZ, Dec 21, 2010
    Last edited: Dec 21, 2010

    LPZ
    macrumors 65816

    Joined:
    Jul 11, 2006
    #10
  11. thread starter macrumors newbie

    Joined:
    Dec 20, 2010
    #11
    yay! the swing-worker.jar file fixed the problem. i put this in the terminal and it launched draw9patch:

    Code:
    Last login: Tue Dec 21 17:44:27 on ttys000
    BURTSON:~ theburt00$ export PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"
    BURTSON:~ theburt00$ /android-sdk-mac_86/tools/draw9patch 
    
    looks like i still need to fix the PATH, but at least its working! let me know if i can fix the PATH as well, but otherwise, thanks for the help!
     
  12. LPZ
    macrumors 65816

    Joined:
    Jul 11, 2006
    #12
    Glad to help. Fixing the PATH environment variable should not be difficult. In Terminal, enter

    Code:
    /bin/cat  ~/.profile
    and post what you get.
     
  13. thread starter macrumors newbie

    Joined:
    Dec 20, 2010
    #13
    ok, here it is:

    Code:
    Last login: Wed Dec 22 18:04:28 on ttys000
    BURTSON:~ theburt00$ /bin/cat  ~/.profile
    cat: /Users/theburt00/.profile: No such file or directory
    BURTSON:~ theburt00$ 
    
     
  14. LPZ
    macrumors 65816

    Joined:
    Jul 11, 2006
    #14
    OK, no .profile file. What do you get from

    Code:
    /bin/cat  ~/.bashrc
    in Terminal?
     
  15. thread starter macrumors newbie

    Joined:
    Dec 20, 2010
    #15
    i get the same thing. i remember putting these commands in before, and i think at the time i was reading something that told me to clear it.

    Code:
    Last login: Wed Dec 22 18:04:55 on ttys000
    BURTSON:~ theburt00$ /bin/cat  ~/.bashrc
    cat: /Users/theburt00/.bashrc: No such file or directory
    BURTSON:~ theburt00$ 
    
     
  16. LPZ
    macrumors 65816

    Joined:
    Jul 11, 2006
    #16
    So where is the PATH variable being set?

    What about

    Code:
    /bin/cat  ~/.login
    in Terminal?
     
  17. thread starter macrumors newbie

    Joined:
    Dec 20, 2010
    #17
    Aah! Same thing again!

    Code:
    Last login: Sun Dec 26 16:16:16 on console
    BURTSON:~ theburt00$ /bin/cat ~/.login
    cat: /Users/theburt00/.login: No such file or directory
    BURTSON:~ theburt00$ 
    
     
  18. macrumors 6502a

    Joined:
    Mar 19, 2008
    Location:
    North Shore, MA
    #18
    One more file to check here. Run:
    Code:
    /bin/cat ~/.bash_profile
     
  19. thread starter macrumors newbie

    Joined:
    Dec 20, 2010
    #19
    Alrighty.

    Code:
    Last login: Mon Dec 27 14:41:01 on console
    BURTSON:~ theburt00$ /bin/cat ~/.bash_profile
    export PATH={PATH}:/Users/theburt00/Documents/android-sdk-mac_86/tools
    
    BURTSON:~ theburt00$ 
    
     
  20. LPZ, Dec 27, 2010
    Last edited: Dec 27, 2010

    LPZ
    macrumors 65816

    Joined:
    Jul 11, 2006
    #20
    That's the source of the problem! That line should be

    Code:
    export PATH=$PATH:/android-sdk-mac_86/tools
    (assuming that the android-sdk-mac_86 folder is still in the root directory of your filesystem).

    To fix, copy and paste the following into Terminal and press return.

    Code:
    rm ~/.bash_profile; touch ~/.bash_profile; echo 'export PATH=$PATH:/android-sdk-mac_86/tools' >> ~/.bash_profile
    To test, quit and restart Terminal. Then enter

    Code:
    cat ~/.bash_profile
    The command should now work, and you should get

    Code:
    export PATH=$PATH:/android-sdk-mac_86/tools
    You should also be able to launch draw9patch by simply entering

    Code:
    draw9patch
    in Terminal.
     
  21. thread starter macrumors newbie

    Joined:
    Dec 20, 2010
    #21
    Yes! It fully works now! Thank you so much for this!
     
  22. macrumors newbie

    Joined:
    Apr 19, 2013
    #22
    I'm very confused about PATH and things like that...

    I have seen videos and GNU manuals about it but even the tutorials for amateurs are very difficult to understand in my opinion. Is there a .profile and PATH tutorial that spells out everything one needs to know to use it?
    anyway, here is my contribution:
    I was having issues with the .profile file in my mac, I was export -ing the PATHS correctly, but file acted like it didn't existed. I deleted that and bash_profile and build new ones, but nothing worked. Then I tried echo $PATH and I could see that one of the PATHS was incorrect. After that I found that I had Macports whatever that is, and somehow that was making trouble. Then I did an ls -alf and I saw that I had many files that normally contain the PATHS: .profile, profile, bash_profile, .bash_profile, .bash_profile.macports-saved-blah blah... anyway I thought I just had too many and I deleted profile (with no period at beginning) and left .profile also deleted bash_profile and that seemed to work!

    Almost 4 hours for this... there is no reason this should be such an issue, where can we find more info about PATH issues?
     
  23. macrumors member

    Joined:
    Jun 17, 2012
    #23
    Hi droide. It's nice that you're interested in learning more about your shell. Maybe this will help a little.

    You're missing some basics about how your shell (bash) works, and you need to learn a little bit of related vocabulary. Rather than a "PATH tutorial," what you really need to look for are answers to questions like:

    What's an environment variable?
    What does it mean to export an environment variable?
    In what order does bash read its start up files? What files are read?
    Are different files read when bash is started as a login shell rather than a non-login shell?

    On invocation, does bash read $HOME/profile or $HOME/bash_profile?

    It may seem daunting, but you should be able to answer those questions well enough by searching though the bash man page.
     

Share This Page