File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Mac OS and the fly likes Compile and run java program in Macintosh Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » Mac OS
Bookmark "Compile and run java program in Macintosh" Watch "Compile and run java program in Macintosh" New topic
Author

Compile and run java program in Macintosh

srinivasrao marri
Ranch Hand

Joined: Feb 13, 2001
Posts: 61
hi
i am new to mac, i am using mac os x(10.2.3)
i am trying to compile and run a java program, i am able to compile but when it comes to running, i am using jbinder to do this , at command i amd giving the class file name and clicking the run button. its saying that
"could not save the specified output file error: -34"
what might be the reason and how can i make it run..moreover i check the disk space its having 157mb of space.
Thanks
srinivas
Sumeet Gaikwad
Ranch Hand

Joined: Mar 07, 2002
Posts: 37
Dear Srinivasrao,
i am using jbinder to do this

Why are you using the jbinder in Mac OS X.?
I am running my application without using the jbinder in Mac OS X.
Mac OS X is java 1.3 compitable. Run the java application from the command prompt (Console) same as in windows.


Sumeet Gaikwad<br />SCJP, SCWCD<br />-----------------------------------------------------------------------------------<br />Nothing is impossible because it spells... I M Possible !!!
srinivasrao marri
Ranch Hand

Joined: Feb 13, 2001
Posts: 61
could u pls tell how to get the console, i heard that mac os x wont have command prompt.
With jbindary the problem is
i am trying to execute a java program in Macintosh os x 10.3.2. When i am clicking run button on jbindery window it giving me an error message saying:

java classpath
unable to launch java application. The main class "HelloWorldApp" could not be loaded. Either it is not in the classpath or has a static iitializer uses a class not in the classpath.

If i need to set the classpath, which zip/jar file i need to set, if i set something , did i need to save the settings?

thanks a lot
srinivas
[ March 03, 2003: Message edited by: srinivasrao marri ]
Sumeet Gaikwad
Ranch Hand

Joined: Mar 07, 2002
Posts: 37
Dear Shrinivasrao,
Mac OS 9 is not having any console, but Mac OS X is having the console. Thats why the javac and jbindary required in Mac OS 9 to compile and run the programme.
Plz search in your Mac throuth Sherlock or finder to find the Console or Terminal. After getting the console you can use the linux command.
Michael Allan
Greenhorn

Joined: Mar 04, 2003
Posts: 4
Originally posted by Sumeet Gaikwad:
Plz search in your Mac throuth Sherlock or finder to find the Console or Terminal. After getting the console you can use the linux command.
Srinivasrao,
Sumeet is right, but just so there's no confusion:
The Console is no good to you - it reports information on crashes, etc. The Terminal is the one you want. It can be found in /Application/Utilities unless you've moved them. Dragging it into the dock would be worthwhile if you're going to be launching it often.
Once you've got Terminal open, cd in to your working directory (dragging a folder onto Terminal will write its path to the window and probably save you some keystrokes) and you can compile and run your java program from there (I don't know anything about jbinder, but it's not necessary). Just do this:
cd ~/Javafiles/SomeFolder/Exercise1
javac HelloWorld.java
java HelloWorld
Happy coding!
srinivasrao marri
Ranch Hand

Joined: Feb 13, 2001
Posts: 61
Hi Michael Allan
Thanks a lot, now i am able to do my java programs using terminal.
Could you please tell me how to set the classpath, i hope for this i need jbindery, is there any other way like autoexe.bat kind of thing where we can give the paths of our library files like jar.
Thank you
With regards
Srinivas
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61105
    
  66

Yes, depending upon what unix shell you are running (I think the default for Darwin is tcsh, though I prefer bash) there will be a login script in which you can set the classpath.
For tsch I believe it is .tschrc (tcsh users, please correct me if this is wrong).
Note that the preceeding dot in the filename makes this a "hidden" file which you will normally not see, but you can edit using vi, pico or emacs with no problems.
I forget the syntax for setting environment variables under tsch, but you should be able to find out by poking around a bit.
In fact, you might want to check out the forums at macosx.com for help on OS X related issues. In particular, you might find the Mac OS X Unix & X11 forum useful.
hth,
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Michael Allan
Greenhorn

Joined: Mar 04, 2003
Posts: 4
Yes, the default shell for os x is tcsh. The hidden configuration file is .tcshrc (small typo there in Bear's response).
The classpath variable can be set as an environment variable using the following syntax:
setenv CLASSPATH /path-to-directory
Check to see that your change stuck with the command:
echo $CLASSPATH
You can also set the classpath for the complier or JVM temporarily (this instruction will override the preset environment variables):
javac -classpath /path-to-directory , or
java -classpath /path-to-directory
*HOWEVER* I'm still a beginner at this, and have *not* been able to get the classpath to work, even for locating a simple library of classes I'd like used by a java file in another directory. I've tried twice now, without success. It looks like understanding the classpath involves quite a lot more than just knowing how to issue commands to affect it, so ....
If *anyone * here is able to expain the classpath I'd be deeply grateful. It's got me stumped.
Sumeet Gaikwad
Ranch Hand

Joined: Mar 07, 2002
Posts: 37
Dear Michael,
I am using the EXPORT command to set the classpath just like in linux.
Do you have any problem using the EXPORT command in Mac OS X.?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Compile and run java program in Macintosh