Java From Terminal

Joined
Mar 14, 2005
Messages
443
Reaction score
3
Points
18
Location
Atlanta, GA
Your Mac's Specs
17" Macbook Pro Unibody 2.66 Ghz and Powerbook G4 1.67 GHz 2.0GB RAM
I have a Powerbook G4 1.3 GHz (OS X)

I have been programming in C and C++ for a while now for school related projects using Xcode and the terminal to compile. I recently recieved a project that requires the use of java. So I downloaded the newest version of Eclipse. I tried to use the application after copying it to my HD and it wouldn't open, yielding some odd java error. I then figured it was my version of java, so i downloaded the newest version of java from the apple webpage, and it said that my version of java did not need to be updated. So i went to the terminal and coded out a small java program that makes random numbers and prints to the screen. I then typed as series of commands as shown below. Each time a new empty command prompt was displayed with no error message.

jamesgaines$ java -version
jamesgaines$

'the directory has my Random_1.java file'
jamesgaines$ javac *.java
jamesgaines$

'Graph is a class file'
jamesgaines$ java Graph
jamesgaines$

None of these used any processes or yielded any output.

Does anyone know what this means or how i can fix it?

I also did a 'where' on java and found that i have all the java files needed to run java, but it would have updated during the update if i had needed anything extra hopefully. Applications that run on java do not work either. Thanks in advance.
 
M

meltbanana314

Guest
XCode is an IDE for Java as well, not just C/C++/Obj-C. Installing Eclipse is kind of redundant.
 
K

Kokopelli

Guest
meltbanana314 said:
Installing Eclipse is kind of redundant.

Not really. It is an alternative that some prefer. I am not too fond of the java support in XCode. I like Mac UI design in XCode (EDIT: I guess technically that is Interface Builder) but for core work or platfom independent code in Java, Eclipse is better suited.

If "java -version" does not return output something is wrong. You might confirm the java framework is installed. "which java" reports a location of /usr/bin/java, which is a link to /System/Library/Frameworks/JavaVM.framework/commands/java you could try navigating there and calling the java command directly and see if it works, might be a bad link from /usr/bin. If all else fails you might try reinstalling java.
 
OP
jdgti
Joined
Mar 14, 2005
Messages
443
Reaction score
3
Points
18
Location
Atlanta, GA
Your Mac's Specs
17" Macbook Pro Unibody 2.66 Ghz and Powerbook G4 1.67 GHz 2.0GB RAM
Kokopelli said:
Not really. It is an alternative that some prefer. I am not too fond of the java support in XCode. I like Mac UI design in XCode (EDIT: I guess technically that is Interface Builder) but for core work or platfom independent code in Java, Eclipse is better suited.

If "java -version" does not return output something is wrong. You might confirm the java framework is installed. "which java" reports a location of /usr/bin/java, which is a link to /System/Library/Frameworks/JavaVM.framework/commands/java you could try navigating there and calling the java command directly and see if it works, might be a bad link from /usr/bin. If all else fails you might try reinstalling java.

Actually i did do a which java, thats what i meant by where, i just mis-typed it. And i executed the command there and it did the same thing. I would personally rather use VI from terminal if you want the truth i was just told that eclipse is really nice.
 
K

Kokopelli

Guest
Try reinstalling java then. Or as much as I hate the panacea, you might try repairing permissions.

I used to live and die by emacs. I tend to use eclipse now for Java and switch between Code Warrior, emacs, and recently XCode for everything else. Eclipse is nice but not a magic bullet. If you don't want to use it don't.

EDIT: You did a "which" to bring you to /usr/bin but did you follow the sim links to the actual location? I am wondering if the links are busted.
 
OP
jdgti
Joined
Mar 14, 2005
Messages
443
Reaction score
3
Points
18
Location
Atlanta, GA
Your Mac's Specs
17" Macbook Pro Unibody 2.66 Ghz and Powerbook G4 1.67 GHz 2.0GB RAM
"repairing permissions" - can you explain this a little better please?

Man, I feel like such a newbie right now. I have used Linux for 1 year and now the darwin/unix interface for 6 months and i can't figure this out. I have never had a real java failure/error/breakdown like this.

So basically i navigated to
:/System/Library/Frameworks/JavaVM.framework/commands jamesgaines$
java is located here. i did an 'ls' command this is what is in the dir.

appletviewer java javap policytool servertool extcheck java-rmi.cgi jdb rmic tnameserv idlj javac keytool rmid jar javadoc native2ascii rmiregistry jarsigner javah ardb serilver

this seems about right. Is there anything else i can do to help someone help me? I really want to have the ability to compile my project. Its very combersome to scp my files every time i want to compile and fix errors and repeat again. I would love to compile from my home machine. Can i REMOVE everything java related CLEANLY somehow and then reinstall. I tried something like this from the cd that came with the computer. I put it in and reinstalled all developer related items. Nothing changed. Like i said i have downloaded the newest release of java from apple.com and it said i didn't need to update... any clues? Thanks in advance.
 
OP
jdgti
Joined
Mar 14, 2005
Messages
443
Reaction score
3
Points
18
Location
Atlanta, GA
Your Mac's Specs
17" Macbook Pro Unibody 2.66 Ghz and Powerbook G4 1.67 GHz 2.0GB RAM
Maybe this will help. I did and ls -l

:/System/Library/Frameworks/JavaVM.framework/commands jamesgaines$ ls -l
total 2528
-rwxr-xr-x 1 root wheel 61236 10 Feb 15:30 appletviewer
-rwxr-xr-x 1 root wheel 61236 10 Feb 15:30 extcheck
-rwxr-xr-x 1 root wheel 61236 10 Feb 15:30 idlj
-rwxr-xr-x 1 root wheel 61236 10 Feb 15:30 jar
-rwxr-xr-x 1 root wheel 61236 10 Feb 15:30 jarsigner
-rwxr-xr-x 1 root wheel 61236 10 Feb 15:30 java
-rwxr-xr-x 1 root wheel 2126 1 Sep 2004 java-rmi.cgi
-rwxr-xr-x 1 root wheel 61236 10 Feb 15:30 javac
-rwxr-xr-x 1 root wheel 61236 10 Feb 15:30 javadoc
-rwxr-xr-x 1 root wheel 61236 10 Feb 15:30 javah
-rwxr-xr-x 1 root wheel 61236 10 Feb 15:30 javap
-rwxr-xr-x 1 root wheel 61236 10 Feb 15:30 jdb
-rwxr-xr-x 1 root wheel 61236 10 Feb 15:30 keytool
-rwxr-xr-x 1 root wheel 61236 10 Feb 15:30 native2ascii
-rwxr-xr-x 1 root wheel 61236 10 Feb 15:30 orbd
-rwxr-xr-x 1 root wheel 61236 10 Feb 15:30 policytool
-rwxr-xr-x 1 root wheel 61236 10 Feb 15:30 rmic
-rwxr-xr-x 1 root wheel 61236 10 Feb 15:30 rmid
-rwxr-xr-x 1 root wheel 61236 10 Feb 15:30 rmiregistry
-rwxr-xr-x 1 root wheel 61236 10 Feb 15:30 serialver
-rwxr-xr-x 1 root wheel 61236 10 Feb 15:30 servertool
-rwxr-xr-x 1 root wheel 61236 10 Feb 15:30 tnameserv
/System/Library/Frameworks/JavaVM.framework/commands jamesgaines$
 
K

Kokopelli

Guest
well that looks right but when I do a java -version I get

java version "1.4.2_05"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_05-141.4)
Java HotSpot(TM) Client VM (build 1.4.2-38, mixed mode)

And I would wager javac is not building a class file so something must be going wrong. I have been in the Linux world for about 4 years, and *nix for 15, but I only got a Mac 3 months ago so here I am a newbie myself. The common answer to all ills on a Mac seems to be repair permissions (which can be done using Disk Utility and some 3d party products like Yasu). I am not fond of giving that as an answer since usually it is not the problem, and if it is I would prefer do make sure it is the problem via command line first. But most Mac users seem to frown upon going to CLI so I don't bother anymore. As it stands you permissions are set properly there so that is not likely to be the problem. I find it odd that you do not get any response positive or negative to the java command. It is grasping at straws but from the command line in that directory can you try ./java -version?
 
OP
jdgti
Joined
Mar 14, 2005
Messages
443
Reaction score
3
Points
18
Location
Atlanta, GA
Your Mac's Specs
17" Macbook Pro Unibody 2.66 Ghz and Powerbook G4 1.67 GHz 2.0GB RAM
Kokopelli said:
well that looks right but when I do a java -version I get

java version "1.4.2_05"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_05-141.4)
Java HotSpot(TM) Client VM (build 1.4.2-38, mixed mode)

And I would wager javac is not building a class file so something must be going wrong. I have been in the Linux world for about 4 years, and *nix for 15, but I only got a Mac 3 months ago so here I am a newbie myself. The common answer to all ills on a Mac seems to be repair permissions (which can be done using Disk Utility and some 3d party products like Yasu). I am not fond of giving that as an answer since usually it is not the problem, and if it is I would prefer do make sure it is the problem via command line first. But most Mac users seem to frown upon going to CLI so I don't bother anymore. As it stands you permissions are set properly there so that is not likely to be the problem. I find it odd that you do not get any response positive or negative to the java command. It is grasping at straws but from the command line in that directory can you try ./java -version?

i tried ./java -version nothing happpend. do you think anyone at the apple store near my house would know anything? What abou tthis Yasu thing?
 
K

Kokopelli

Guest
Genius Bar is worth a try. Yasu won't help, your permissions are correct for those files. In *nix terms all YASU or repair permissions does is go through the standard file system and makes sure that the permissions match what they are supposed to for each folder. i.e. /usr/bin should be owned by root:wheel and have a minimum permission of 555. If the permissions do not match the default mask it sets them to at least be compliant if the minimal values.

Occasionally an install will screw up the permissions for a folder and thus cause things to not work right. In the *nix world it is expected that if something like this would happen that the user would discover the problem and chmod/chown the files to an appropriate value. To force this on a Mac or typical non *nix user would cuase undue headaches and spoil the pleasant experience.

Did you install the developers kit, or whatever Apple calls it? (XCode and all that?) If so... Well either way you might try installing or reinstalling it. Could not hurt. Either that or as you suggested hit up the genius bar at the local Apple Store.
 
OP
jdgti
Joined
Mar 14, 2005
Messages
443
Reaction score
3
Points
18
Location
Atlanta, GA
Your Mac's Specs
17" Macbook Pro Unibody 2.66 Ghz and Powerbook G4 1.67 GHz 2.0GB RAM
Genius Bar... Not Genius. They didn't know what to do. But I found a way around it though. I just reinstalled the OS 'Archived' Style. So I didn't loose any of my precious files. :)

Thanks for all your help guys.

This is the most beautiful line from terminal to see now that java works.

jamesgaines$ java -version
java version "1.4.2_05"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_05-141.3)
Java HotSpot(TM) Client VM (build 1.4.2-38, mixed mode)
jamesgaines$

Wonderful :cool:
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top