Find the answer to your Linux question:
Results 1 to 4 of 4
I am trying to compile java files manually using javac from a terminal. I have read many posts on how to add java into the class path/path/root, etc. But I ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Feb 2010
    Posts
    2

    What the heck is in my root path?


    I am trying to compile java files manually using javac from a terminal. I have read many posts on how to add java into the class path/path/root, etc. But I have only been using linux for about 3 days now. I have Ubuntu distribution. I installed the latest SDK included with Netbeans. I can't figure out Netbeans at the moment so I want to just write simple applets, compile them from a terminal, and put them on my websites. I tried adding java to my path already, so I would also like to know how to find out what is currently in it.

    I really do not understand the file structure in Linux so far. It seems like you don't have drive letters in this operating system? I am quite lost on running commands from the terminal so any help would be appreciated. Seems like I used to be able to type "javac JavaFileName.java" and a class file would be generated. I think the only way to be able to do that is to add java into the System Root Path.

    Carter

  2. #2
    Linux Guru
    Join Date
    Nov 2007
    Posts
    1,754
    When you open a command prompt in Windows, you have a path variable. And just the same, Linux has a path variable.

    For any system variables:

    Code:
    echo $PATH
    To see all variables:

    Code:
    env
    Google: linux filesystem

  3. #3
    Just Joined!
    Join Date
    Feb 2010
    Posts
    2
    Hey thanks a lot. That is really helpful. Now I know I don't have java in my system path... So... Can anyone tell me how to get it so that I can compile java files within the terminal without typing out full path everytime?

  4. #4
    Linux Engineer Thrillhouse's Avatar
    Join Date
    Jun 2006
    Location
    Arlington, VA, USA
    Posts
    1,377
    You have to find where the java compiler was installed. The whereis command may be useful here. Once you locate javac, you'll want to put it into your path. For instance, my javac is located in /opt/jdk1.6.0_11/bin/javac. To get that into my PATH, I would do:
    Code:
    export PATH=$PATH:/opt/jdk1.6.0_11/bin

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •