Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Dec 20, 2010, 04:16 PM   #1
aburtson
macrumors newbie
 
Join Date: Dec 2010
Help! Terminal won't run .jar file

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!
aburtson is offline   0 Reply With Quote
Old Dec 20, 2010, 05:00 PM   #2
LPZ
macrumors 65816
 
Join Date: Jul 2006
What do you get from the following in Terminal:

Code:
echo $SHELL; echo $PATH; which dirname basename

Last edited by LPZ; Dec 20, 2010 at 05:15 PM.
LPZ is offline   0 Reply With Quote
Old Dec 20, 2010, 07:31 PM   #3
aburtson
Thread Starter
macrumors newbie
 
Join Date: Dec 2010
Quote:
Originally Posted by LPZ View Post
What do you get from the following in Terminal:

Code:
echo $SHELL; echo $PATH; which dirname basename
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!
aburtson is offline   0 Reply With Quote
Old Dec 20, 2010, 07:53 PM   #4
talmy
macrumors 601
 
talmy's Avatar
 
Join Date: Oct 2009
Location: Oregon
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.
__________________
27" i7 iMac, 15" MacBook Pro, Mac mini with Yosemite Server, 5 other Macs and an unused Apple TV in the household.
talmy is offline   0 Reply With Quote
Old Dec 20, 2010, 08:22 PM   #5
aburtson
Thread Starter
macrumors newbie
 
Join Date: Dec 2010
Quote:
Originally Posted by talmy View Post
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.
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
aburtson is offline   0 Reply With Quote
Old Dec 20, 2010, 09:07 PM   #6
LPZ
macrumors 65816
 
Join Date: Jul 2006
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.
LPZ is offline   0 Reply With Quote
Old Dec 20, 2010, 09:42 PM   #7
aburtson
Thread Starter
macrumors newbie
 
Join Date: Dec 2010
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$
aburtson is offline   0 Reply With Quote
Old Dec 21, 2010, 01:51 AM   #8
chown33
macrumors 603
 
Join Date: Aug 2009
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:
Quote:
In Terminal, enter
Code:
export PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"
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.
chown33 is offline   0 Reply With Quote
Old Dec 21, 2010, 05:18 PM   #9
aburtson
Thread Starter
macrumors newbie
 
Join Date: Dec 2010
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$
aburtson is offline   0 Reply With Quote
Old Dec 21, 2010, 05:33 PM   #10
LPZ
macrumors 65816
 
Join Date: Jul 2006
This is now a Java-related error (so you have made progress).

In Terminal, enter

Code:
java -version
[EDIT] See here: http://droidreign.com/2010/12/soluti...rk-on-2-3-sdk/

Last edited by LPZ; Dec 21, 2010 at 05:56 PM.
LPZ is offline   0 Reply With Quote
Old Dec 21, 2010, 08:47 PM   #11
aburtson
Thread Starter
macrumors newbie
 
Join Date: Dec 2010
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!
aburtson is offline   0 Reply With Quote
Old Dec 22, 2010, 05:42 AM   #12
LPZ
macrumors 65816
 
Join Date: Jul 2006
Quote:
Originally Posted by aburtson View Post
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!
Glad to help. Fixing the PATH environment variable should not be difficult. In Terminal, enter

Code:
/bin/cat  ~/.profile
and post what you get.
LPZ is offline   0 Reply With Quote
Old Dec 22, 2010, 09:05 PM   #13
aburtson
Thread Starter
macrumors newbie
 
Join Date: Dec 2010
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$
aburtson is offline   0 Reply With Quote
Old Dec 22, 2010, 09:27 PM   #14
LPZ
macrumors 65816
 
Join Date: Jul 2006
Quote:
Originally Posted by aburtson View Post
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$
OK, no .profile file. What do you get from

Code:
/bin/cat  ~/.bashrc
in Terminal?
LPZ is offline   0 Reply With Quote
Old Dec 23, 2010, 05:25 AM   #15
aburtson
Thread Starter
macrumors newbie
 
Join Date: Dec 2010
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$
aburtson is offline   0 Reply With Quote
Old Dec 23, 2010, 05:30 AM   #16
LPZ
macrumors 65816
 
Join Date: Jul 2006
Quote:
Originally Posted by aburtson View Post
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$
So where is the PATH variable being set?

What about

Code:
/bin/cat  ~/.login
in Terminal?
LPZ is offline   0 Reply With Quote
Old Dec 27, 2010, 04:21 AM   #17
aburtson
Thread Starter
macrumors newbie
 
Join Date: Dec 2010
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$
aburtson is offline   0 Reply With Quote
Old Dec 27, 2010, 06:48 AM   #18
Guiyon
macrumors 6502a
 
Join Date: Mar 2008
Location: North Shore, MA
One more file to check here. Run:
Code:
/bin/cat ~/.bash_profile
__________________
Make life easier if you have a programming question!
http://www.sscce.org/
Guiyon is offline   0 Reply With Quote
Old Dec 27, 2010, 07:13 PM   #19
aburtson
Thread Starter
macrumors newbie
 
Join Date: Dec 2010
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$
aburtson is offline   0 Reply With Quote
Old Dec 27, 2010, 07:41 PM   #20
LPZ
macrumors 65816
 
Join Date: Jul 2006
Quote:
Originally Posted by aburtson View Post
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$
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.

Last edited by LPZ; Dec 27, 2010 at 07:52 PM.
LPZ is offline   0 Reply With Quote
Old Dec 29, 2010, 10:19 PM   #21
aburtson
Thread Starter
macrumors newbie
 
Join Date: Dec 2010
Yes! It fully works now! Thank you so much for this!
aburtson is offline   0 Reply With Quote
Old Apr 19, 2013, 06:39 PM   #22
Droide
macrumors newbie
 
Join Date: Apr 2013
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?
Droide is offline   0 Reply With Quote
Old Apr 20, 2013, 06:50 PM   #23
pitaya
macrumors member
 
Join Date: Jun 2012
Hi droide. It's nice that you're interested in learning more about your shell. Maybe this will help a little.

Quote:
Originally Posted by Droide View Post
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?
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?

Quote:
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!
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.
pitaya is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Finder file path dropped in terminal - won't work with some locations dylan873 Mac Basics and Help 1 Nov 26, 2013 09:11 AM
The Java JAR file “whatever.jar” could not be launched. Shivetya OS X 0 Jul 31, 2013 05:33 PM
MBP (Late 2011) Unable to access Jar File... DEATHCON51 MacBook Pro 5 Jan 17, 2013 09:17 PM
Run MySQL on terminal dwolny Mac Programming 1 Nov 2, 2012 02:25 PM
Error on terminal when trying to run application, help? bigben33 OS X 10.8 Mountain Lion 2 Oct 21, 2012 12:06 AM

Forum Jump

All times are GMT -5. The time now is 01:43 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC