New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Development and Darwin Discussion and questions about development for Mac OS X.

Java From Terminal


Post Reply New Thread Subscribe

 
Thread Tools
jdgti

 
jdgti's Avatar
 
Member Since: Mar 14, 2005
Location: Atlanta, GA
Posts: 444
jdgti will become famous soon enough
Mac Specs: 17" Macbook Pro Unibody 2.66 Ghz and Powerbook G4 1.67 GHz 2.0GB RAM

jdgti is offline
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.
QUOTE Thanks
meltbanana314
Guest
 
Posts: n/a

XCode is an IDE for Java as well, not just C/C++/Obj-C. Installing Eclipse is kind of redundant.
QUOTE Thanks
Kokopelli
Guest
 
Posts: n/a

Quote:
Originally Posted by meltbanana314
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.
QUOTE Thanks
jdgti

 
jdgti's Avatar
 
Member Since: Mar 14, 2005
Location: Atlanta, GA
Posts: 444
jdgti will become famous soon enough
Mac Specs: 17" Macbook Pro Unibody 2.66 Ghz and Powerbook G4 1.67 GHz 2.0GB RAM

jdgti is offline
Quote:
Originally Posted by Kokopelli
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.
QUOTE Thanks
Kokopelli
Guest
 
Posts: n/a

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.
QUOTE Thanks
jdgti

 
jdgti's Avatar
 
Member Since: Mar 14, 2005
Location: Atlanta, GA
Posts: 444
jdgti will become famous soon enough
Mac Specs: 17" Macbook Pro Unibody 2.66 Ghz and Powerbook G4 1.67 GHz 2.0GB RAM

jdgti is offline
"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.
QUOTE Thanks
jdgti

 
jdgti's Avatar
 
Member Since: Mar 14, 2005
Location: Atlanta, GA
Posts: 444
jdgti will become famous soon enough
Mac Specs: 17" Macbook Pro Unibody 2.66 Ghz and Powerbook G4 1.67 GHz 2.0GB RAM

jdgti is offline
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$
QUOTE Thanks
Kokopelli
Guest
 
Posts: n/a

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?
QUOTE Thanks
jdgti

 
jdgti's Avatar
 
Member Since: Mar 14, 2005
Location: Atlanta, GA
Posts: 444
jdgti will become famous soon enough
Mac Specs: 17" Macbook Pro Unibody 2.66 Ghz and Powerbook G4 1.67 GHz 2.0GB RAM

jdgti is offline
Quote:
Originally Posted by Kokopelli
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?
QUOTE Thanks
Kokopelli
Guest
 
Posts: n/a

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.
QUOTE Thanks
jdgti

 
jdgti's Avatar
 
Member Since: Mar 14, 2005
Location: Atlanta, GA
Posts: 444
jdgti will become famous soon enough
Mac Specs: 17" Macbook Pro Unibody 2.66 Ghz and Powerbook G4 1.67 GHz 2.0GB RAM

jdgti is offline
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:
QUOTE Thanks

Post Reply New Thread Subscribe


« iBook and C | System Startup »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
Java update 1.4.1 is out rman OS X - Operating System 1 04-30-2006 01:05 PM
Java Update 1.4.1 for Panther released Murlyn OS X - Operating System 0 11-13-2003 01:57 PM
Apple posts QuickTime for Java update 6.4 Murlyn Running Windows (or anything else) on your Mac 0 10-24-2003 11:06 AM
Apple Releases Java Update schweb Apple Rumors and Reports 0 09-08-2003 06:23 PM
Apple Releases Java 1.4.1 Graphite Apple Rumors and Reports 5 03-10-2003 07:52 PM

All times are GMT -4. The time now is 11:44 PM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?