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 Bashing my Tiger, where's the other one? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Mac OS
Bookmark "Bashing my Tiger, where Watch "Bashing my Tiger, where New topic
Author

Bashing my Tiger, where's the other one?

Bryan Eckhardt
Greenhorn

Joined: Jun 06, 2012
Posts: 5
I'm having difficulties finding the JVM on my Mac 10.6.8. I have downloaded and installed the most recent JAVA additions. What files I found said I had to change the export path in a file labeled bashrc or in a JVM file. I tried searching through all the hidden files to find a "bashrc" file, and the "JVM" or "J virtual machine" itself without any luck. I do not have trouble finding the compiler which I found using the "which" command. Who knew they were not located in the same spot...The only thing I can think of is that it's under a different name than what is in the book, possibly.
Tim McGuire
Ranch Hand

Joined: Apr 30, 2003
Posts: 820

the file name is .bashrc instead of bashrc and it is not there by default. You may have to create it.
Tim McGuire
Ranch Hand

Joined: Apr 30, 2003
Posts: 820

If you type 'which java' at the command prompt, it will show the path to _a_ java executable. On mine it returns the path to the jdk bin directory. You have to put that into your newly created .bashrc with a line like

export PATH=$PATH:/usr/java/jdk1.5.0_07/bin
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60059
    
  65

For me, Java is installed at:

/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bryan Eckhardt
Greenhorn

Joined: Jun 06, 2012
Posts: 5
UPDATE:
I'm a newb at this. I attempted to make a bashrc file but this did not work for me. The compiler spit out a file with errors when I used the export statement. Is this supposed to be the only statement in the methods of that class? The error message I'm getting is "-bash: fg: %java: no such job" when I attempt to run the MyFirstApp.class. Is there any additional information that might help?
Tim McGuire
Ranch Hand

Joined: Apr 30, 2003
Posts: 820

Bryan Eckhardt wrote:UPDATE:
I attempted to make a bashrc file but this did not work for me. The compiler spit out a file with errors when I used the export statement. Is this supposed to be the only statement in the methods of that class? The error message I'm getting is "-bash: fg: %java: no such job" when I attempt to run the MyFirstApp.class. Is there any additional information that might help?


1. Did you call the file "bashrc" or ".bashrc" ??
2. Read this about .bash_profile and ".bashrc" to see if .bash_profile is better for your needs: http://www.joshstaiger.org/archives/2005/07/bash_profile_vs.html
3. The java compiler should not be encountering the export statement! Are you using the export command inside a java class? Don't do that.
4. please post the code of MyFirstApp.java (and use code tags)

Tim
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2771
    
  10

Hi Bryan, and by the way, welcome to JavaRanch!

I'm confused by several points of your problem. First you say you have a path to javac, but not java. I could understand the reverse being true, because JREs have java, but not javac. JDKs, however, always have both. I've never seen a bin directory that contained javac, but not java. What is your output from "which javac"? Are you sure there's no java in that directory? If that's really the case, then reinstalling may be in order.

The advice with bashrc is trying to get you to set your path so it points to another Java location. If you're having trouble getting it to work with bashrc, just get rid of it and try setting the path from the command line for the time being. When you get that working, you can worry about automating it so it runs automatically whenever you open a terminal window.



shows you what the path is currently.


sets the path to point to your new directory.


Technically, you don't need the word export in there, because all that does is promote PATH to the status of environment variable, which it already is. It's just a good habit to always "export" variables you want to be in your environment. Also, don't worry if you don't really understand what environment means yet.

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60059
    
  65

I'm really confused by the OP's problem now.

Here's the skinny:

The bash shell on OS X comes with a .bash_profile in the home folder. This is the config file you should be adding anything to.

But... you shouldn't have to add anything if much.

My PATH starts with:

/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/bin

and I didn't need to do anything to set that up.

So the questions are:
  • Do you have a .bash_profile file in your home folder? (Don;t look with Finder, it wont show it. Open a Terminal window and do "ls -al")
  • At the command prompt type "echo $PATH" -- what does it show?


  • All the mucking around you're doing is likely just causing more problems.
    Bryan Eckhardt
    Greenhorn

    Joined: Jun 06, 2012
    Posts: 5
    1. Did you call the file "bashrc" or ".bashrc" ??

    ".bashrc" and then "bashrc"

    2. Read this about .bash_profile and ".bashrc" to see if .bash_profile is better for your needs: http://www.joshstaiger.org/archives/2005/07/bash_profile_vs.html

    According to this .bash_profile maybe more appropriate. I am running on a Mac OSX.

    3. The java compiler should not be encountering the export statement! Are you using the export command inside a java class? Don't do that.

    Yes, I was using the export statement in a class. Where is it supposed to go if not in a class?

    4. please post the code of MyFirstApp.java (and use code tags)

    I began reading this Head First Java book and decided to start programming from the examples. This is the first one.

    Bear Bibeault
    Author and ninkuma
    Marshal

    Joined: Jan 10, 2002
    Posts: 60059
        
      65

    Bryan Eckhardt wrote:
    According to this .bash_profile maybe more appropriate. I am running on a Mac OSX.

    Yes, read my post. You should already have a .bash_profile unless you deleted it?

    Yes, I was using the export statement in a class. Where is it supposed to go if not in a class?

    Why would you be putting bash commands in a Java class?

    Please answer the questions I posted.
    Bryan Eckhardt
    Greenhorn

    Joined: Jun 06, 2012
    Posts: 5
    Bear Bibeault wrote:
    Bryan Eckhardt wrote:
    According to this .bash_profile maybe more appropriate. I am running on a Mac OSX.

    Yes, read my post. You should already have a .bash_profile unless you deleted it?


    Located a bash_history file but not a .bash_profile. Where is that usually located?

    Bear Bibeault wrote:
    Bryan Eckhardt wrote:Yes, I was using the export statement in a class. Where is it supposed to go if not in a class?

    Why would you be putting bash commands in a Java class?


    As a newb, I was going off of information on websites that said to make a file for bash commands. I assumed it was for Java.

    THOUGH, I solved the problem. All it took was a new light. I discovered I can get a list of commands when typing "java" and the command that I needed is different than the one in the book. Pretty simple. doh.
    Bear Bibeault
    Author and ninkuma
    Marshal

    Joined: Jan 10, 2002
    Posts: 60059
        
      65

    Bryan Eckhardt wrote:Located a bash_history file but not a .bash_profile. Where is that usually located?

    home folder

    If you don't have one, create one with either the touch command or a text editor. Make sure it's a plain text file, not an rtf or word document.

    I solved the problem. All it took was a new light. I discovered I can get a list of commands when typing "java" and the command that I needed is different than the one in the book. Pretty simple. doh


    Please post the differences here. Others are likely to find it helpful.
    Bryan Eckhardt
    Greenhorn

    Joined: Jun 06, 2012
    Posts: 5
    Bear Bibeault wrote:
    Bryan Eckhardt wrote:Located a bash_history file but not a .bash_profile. Where is that usually located?

    home folder

    If you don't have one, create one with either the touch command or a text editor. Make sure it's a plain text file, not an rtf or word document.

    I solved the problem. All it took was a new light. I discovered I can get a list of commands when typing "java" and the command that I needed is different than the one in the book. Pretty simple. doh


    Please post the differences here. Others are likely to find it helpful.


    The book, "Head First Java" uses "% Java" to run the class in the text, whereas Mac OSX uses "Java" to run the class.
    Bear Bibeault
    Author and ninkuma
    Marshal

    Joined: Jan 10, 2002
    Posts: 60059
        
      65

    The % is not part of the command. It just indicates the command prompt. All operating systems just use "java".
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Bashing my Tiger, where's the other one?
     
    Similar Threads
    System requirements, JVM version?
    getting the <APPLET> tag to work
    WSAD 5.1.2...Going Crazy!!! java.lang.Object
    Problems with a batch process using Java+Unix
    How to catch ClientAbortException in Tomcat hosted servlets