I'm trying to connect java to a Oracle database within terminal. I'm not very good at terminal and have been struggling with this for 3+ hours. Can someone explain to me how I can properly set my PATH so that java can see the necessary jar files, as well as how to configure my path so that I don't have to type in the path where java is installed everytime I want to compile and run. I undersatnd this is a question that can be googled, but I've been runninginto problem after problem. Please keep in mind that I'm doing this all through PuTTY as I am not on the machine itself. If someone could take the time to answer this question, I would really appreciate it.
-
It would be most helpful if we knew the OS you were using; different OSes have different environment variables that may be required.Adam Musch– Adam Musch2012-01-11 17:30:56 +00:00Commented Jan 11, 2012 at 17:30
-
I'm on a windows machine but using PuTTY to ssh into a Linux machineuser941401– user9414012012-01-11 18:19:16 +00:00Commented Jan 11, 2012 at 18:19
Add a comment
|
1 Answer
Java doesn't find jar files using the PATH. It finds them using the classpath you pass to the java command (or using the CLASSPATH environment variable, but I wouldn't recommend using it outside of a local terminal session):
java -cp /path/to/jar1.jar:/path/to/jar2.jar com.foo.bar.Main
To have the JDK in your path, you need to add <JDK_PATH>/bin (or <JDK_PATH>\bin on Windows) to the PATH environment variable.
Read the following section of the Java tutorial.