Setting classpath to ojdbc.jar on UNIX

I�m trying to connect to an Oracle database using the ojdbc.jar
Class.forName("oracle.jdbc.driver.OracleDriver");
How do I set the classpath on Unix to look inside the .jar file? I know it�s the correct driver because I�ve pulled the oracle/jdbc/driver/* folder from the jar file.

How do I set the classpath on Unix to look inside the .jar file?http://www.google.com/search?hl=en&q=how+to+set+a+classpath+in+unix

Similar Messages

  • Setting classpath to execute jar file.

    I have dependency jar files to execute my jar file.
    set classpath=./lib/tpc.jar;./lib/jxl.jar;
          ./lib/log4j-1.2.15.jar;./lib/logSys.jar;
    java -jar ./lib/tpc.jar %1java -jar seems not taking classpath environment variables and showing error as
    Exception in thread "main" java.lang.NoClassDefFoundError:
    com/sys/logger/LogManager
            at utility.tpc.generate.Tpc.generate(Unknown Source)
            at utility.tpc.generate.Tpc.main(Unknown Source)The below one works, but I dont want to give all jar files along with java command and to make complicate.
    java -cp "./lib/tpc.jar;./lib/jxl.jar;./lib/log4j-1.2.15.jar;./lib/logSys.jar;"
             utility.tpc.generate.Tpc %1Is there a way to make first one to work ? Will adding "Class-Path:jxl.jar,log4j-1.2.15.jar,logSys.jar" in my manifest file make it work ?

    baskark wrote:
    I have dependency jar files to execute my jar file.
    set classpath=./lib/tpc.jar;./lib/jxl.jar;
    ./lib/log4j-1.2.15.jar;./lib/logSys.jar;
    java -jar ./lib/tpc.jar %1java -jar seems not taking classpath environment variables and showing error as
    Exception in thread "main" java.lang.NoClassDefFoundError:
    com/sys/logger/LogManager
    at utility.tpc.generate.Tpc.generate(Unknown Source)
    at utility.tpc.generate.Tpc.main(Unknown Source)The below one works, but I dont want to give all jar files along with java command and to make complicate.
    java -cp "./lib/tpc.jar;./lib/jxl.jar;./lib/log4j-1.2.15.jar;./lib/logSys.jar;"
    utility.tpc.generate.Tpc %1Is there a way to make first one to work ? Will adding "Class-Path:jxl.jar,log4j-1.2.15.jar,logSys.jar" in my manifest file make it work ?The jar command is specified to work as you have shown. That is, when you use "java -jar..." the system or command line classpath is ignored. The only classpath that can be used with "java -jar..." is the Class-Path in the manifest. You need to separate the different paths using space characters, not ; or : and the paths need to be relative to the jar file. (I am not sure if "./" will work and it is not needed to specify relative to the jar file.)
    Edited by: atmguy on Dec 14, 2009 8:42 AM

  • Setting Classpath so one jar can access another jar

    I am having trouble with running an application as a jar that accesses other custom libraries.
    I have made a small example to try to get this working.
    I have
         HelloWorld.class - that prints out "HelloWorld" and then throws a custom exception JWIException
         JWIException - exception that is in a package com.jeffersonwells.util
    I have put the JWIException class in the directory D:\apps\jbin\com\jeffersonwells\util.
    I have a manifest file that looks like the following.
         Manifest-Version: 1.0
         Main-Class: HelloWorld
         Class-Path: "d:\apps\jbin\"
    I have created a jar with the manifest file and the HelloWorld class
    When I run the jar, I get the following
         Exception in thread "main" java.lang.NoClassDefFoundError: com/jeffersonwells/util/JWIException
    So, I believe the classpath is not being set correctly.
    Then the second part would be to get the HelloWorld app to access the JWIException in another jar file instead of in the directory structure. I assume if the first scenario gets working, this will be fixed as well.
    I would greatly appreciate any assistance you can provide.
    Thanks,
    Tom Krueger

    I thank you all very much. The problem I was having was with not having relative paths in my Class-Path.
    Having the relative paths will work for the most part, however, sometimes we may want to move the executable jar to a different location. Does anyone have a great solution taking the following into consideration.
    Previous posts have said you can reference classpaths through http or ftp. Great, however if you set this to your http://domain/whatever I'm assuming this will prohibit you from moving the application from dev to test to production without modifying the url.
    Thanks for any thoughts!!
    P.S.
    I'm also in a battle here whether to jar libraries or not. jaring allows you to easily move them from server to server and more importantly for me determine versions of compatible files. However, the argument against jaring is speed of development, why jar if I can pull up a java file compile it and copy it to the server. Why waste time in the whole jaring process.
    Thanks again!!!

  • Need to set classpath if i jar my classes???

    as above?
    Do i need to set?
    why sometimes even though i never set my classpath, my application still runs?
    Thanks

    Your JAR file must be in the classpath.
    Setting the class path
    http://java.sun.com/j2se/1.4/docs/tooldocs/win32/classpath.html
    Jesper

  • Set Classpath during runtime

    How can we set classpath to a .jar file during runtime. Is it possible to set classpath not other than editing a .bat file or by manually editing the global variables list????

    You need to implement you own Class Loader if you want to load a jar at runtime. Why would you like to do that in AS?

  • In UNIX how to set classpath

    I know nothing about UNIX. pls kindly give me some instruction on how to set classpath in UNIX, thanks!

    best way is to set in your .profile (name differs between different shells, but whatever the OS/Shell is, it should starts with . and has a 'profile' string in the name). Try ls -a to find the file, edit it, insert lines like this:
    CLASSPATH=xxxx
    export CLASSPATH
    Use : to seperate different path/files.
    then every time when you log in, the classpath is setted.
    if you already logged in, use the above lines in command line, but it only set class path of the current shell/console.
    anyway, you should learn Unix before you do anything, or you'll have more trouble. do a search in yahoo or google to find on line tuturials, and SUN's Java tuturial has some basic instructions on how to use Java in Unix.

  • How to use jar files without setting classpath

    Hi,
    I have a situvation, I can not set classpath, but i have to use jar files, how can I do that.

    URL[] urls = new URL[]{pathToJar, pathToAnotherJar, ...};
    URLClassLoader urlc = new URLClassLoader(urls);
    Now load classes within the jars loaded by the urlc classloader as needed. This is a limited approach, you can mostly use interfaces to work with classes loaded by the custom loader instance above and your existing classes.

  • Once i set classpath to servlet-api.jar, it doesnt Instantiate DbBean.

    I am using notepad editor. I am trying to instantiate a DbBean class inside the servlet's init() method.
    once i set (C:\Program Files\Apache Software Foundation\Tomcat 5.0\common\lib\servlet-api.jar) this path to compile the Controller servlet.
    C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\ROOT\WEB-INF\classes>set classpath=C:\Program Files\Apache Software Foundation\Tomcat 5.0\common\lib\servlet-api.jar
    C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\ROOT\WEB-INF\classes>javac Controller.java
    Controller.java:5: package bean does not exist
    import bean.DbBean;
    ^
    Controller.java:14: cannot find symbol
    symbol : class DbBean
    location: class Controller
    DbBean dbbean = new DbBean();
    ^
    Controller.java:14: cannot find symbol
    symbol : class DbBean
    location: class Controller
    DbBean dbbean = new DbBean();
    ^
    3 errors
    C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\ROOT\WEB-INF\classes>
    this is my servlet
    import java.sql.*;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import bean.DbBean;
    public class Controller extends HttpServlet
    public void init(ServletConfig config)throws ServletException
    ServletContext context = config.getServletContext();
    context.setAttribute("base_url",config.getInitParameter("base_url"));
    {color:#ff0000}DbBean dbbean = new DbBean();{color} {color:#0000ff}error showing in this line
    {color}dbbean.setDburl(config.getInitParameter("dburl"));
    dbbean.setUserName(config.getInitParameter("username"));
    dbbean.setPassward(config.getInitParameter("pwd"));
    /// database bean can be access from jsp page
    context.setAttribute("dbbean",dbbean);
    /// Load the data base driver
    try{
    Class.forName(config.getInitParameter("jdbcDriver"));
    catch(ClassNotFoundException e)
    System.out.println(e.toString());
    super.init(config);
    public void doGet(HttpServletRequest req, HttpServletResponse res)throws ServletException,IOException
    doPost(req,res);
    public void doPost(HttpServletRequest req, HttpServletResponse res)throws ServletException,IOException
    String base = "/onlinetest1/";
    String url = base + "login.jsp";
    String action = req.getParameter("action");
    if(action!=null)
    if(action.equals("successlogin.jsp"));
    url = base + "successlogin.jsp";
    RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(url);
    dispatcher.forward(req,res);
    public void destroy()
    System.out.println("Servlet stopped");
    This below class can be put inside bean folder( (ie)sub dir of controller servlet)
    package bean;
    import java.sql.*;
    import java.util.*;
    import java.io.*;
    public class DbBean
    String dburl="";
    String dbuser="";
    String dbpass="";
    public void setDburl(String url)
    dburl = url;
    public void setUserName(String uname)
    dbuser = uname;
    public void setPassward(String pwd)
    dbpass = pwd;
    What to do to rectify this, please help me why this error coming,

    hi,
    Actually i did my ordinary package compilation example below, its run correctly, but after set classpath to %tomcat-home%\common\lib\servlet-api.jar(for same programs its not working) this kinds of error coming.
    F:\shyam\test>javac first.java
    F:\shyam\test>java first
    main class
    DB Set Correctly
    F:\shyam\test>set classpath=C:\Program Files\Apache Software Foundation\Tomcat 5.0\common\lib\servlet-api.jar
    F:\shyam\test>javac first.java
    first.java:1: package bean does not exist
    import bean.DbBean;
    ^
    first.java:10: cannot find symbol
    symbol : class DbBean
    location: class first
    DbBean dbbean = new DbBean();
    ^
    first.java:10: cannot find symbol
    symbol : class DbBean
    location: class first
    DbBean dbbean = new DbBean();
    ^
    3 errors
    F:\shyam\test>
    In compilation it wont take DbBean class, please help me.
    thanks in advance,
    S.Shyam

  • Set Classpath to .jar

    I try to create a step in sequence editor to execute a Java class developed by me (following the Computer.seq Java example given). The Java class uses API packaged in a .jar file.
    I tried to
    1. set the classpath to the jar file in Edit Java Class Path Location for Start JVM step and
    2. extract the classes in the jar into a directory set in Configure/Search Directories. 
    When executing the step, I got the following error:
    Details: Error executing substep 'Post'.
                 Cannot find class
    Error Code: -1500; User-defined error code.
    Please advice.
    Thanks

    Hi Wong,
    If you check this error code within the ReadMe in the example folder you can see that this error means "The provided class name was not found in the class path. Verify the class name and that the file containing the class exists in the class path."  Therefore, I think that you may have the incorrect class path set.  Although you selected in the Edit Java Class Path Location and browsed to your jar file, there are a couple things happening here that I believe are causing you to get the error.  First, the dialog is looking for a folder directory that contains your class files, not a jar file.  Also, make sure you point to a folder and not a specific file.  Also, if you look at the pre-expression of this step, you will see that it sets the class path to the example folder.  This value is overwriting anything that you place in the dialog box.  Therefore, delete the pre-expression for the step and then add the directory that your classes are located in to the Edit Java Class Path Location dialog box.
    Let me know if this helps you.
    Thanks,
    Caroline Tipton
    Data Management Product Manager
    National Instruments

  • Setting classpath in bat file

    Hi,
    I'm trying to call my java app from a bat file, normally I put all references to jar files hard coded in the bat file, but now I would like to loop over a lib directory and add all jars in that directory to the classpath:
    I tried the FOR loop of Windows batch like this:
    FOR /R .\lib %%G IN (*.jar) DO set CLASSPATH=%CLASSPATH%;%%G
    but the classpath only contains the last jar file of the directory, what is wrong with that line? A for loop on unix is no problem.
    THX

    Hi,
    I had teh same need, but neither
    FOR /R .\lib %%G IN (*.jar) DO set CLASSPATH=!CLASSPATH!;%%G
    works for me nor
    FOR /R .\lib %%G IN (*.jar) DO set CLASSPATH=%CLASSPATH%;%%G
    I have set the "ENABLEDELAYEDEXPANSION" also
    Regards

  • Set CLASSPATH  in Oracle

    I HAVE CREATED THE JAVA PROGRAM TO READ FROM EXCEL AND STORED INTO DATABASE,
    i loaded the abc.class into oracle using loadjava command,
    AND also created the procedure based on loaded class,
    when i call the procedure, i got the error because i need to set classpath in oracle
    i.e i need to SET the classpath for the classes12.jar , i set the path in environment variables,
    when i run the .class file its working fine,
    can any one tell me , how to set the classpath in oracle, or reference to classes12.jar

    You don't set the classpath in Oracle; you set the environment variable CLASSPATH for your OS.
    For example, it may looks like this in UNIX:
    setenv CLASSPATH $CLASSPATH:$ORACLE_HOME/jlib/some_jar_file.jar

  • Set classpath in JAXB - schemagen

    Using JAXB -(schemagen.bat) i need to create the .xsd file.
    To which , should i set the classpath.
    (TO schemagen.bat OR any-other jar file )
    After setting the classpath, how can i run it to create the .xsd
    (Is this the way???)
    c:\>schemagen MyJfile.java
    C:\jaxb-ri-20060801\bin>schemagen.bat
    When i do this it gives an exception like this -->
    Exception in thread "main" java.lang.NoClassDefFoundError: Files\Java\jdk1/5/0_0
    6\lib;/;F:\java\packages;C:\Program
    https://jaxb.dev.java.net/nonav/2.0.2/docs/schemagen.html

    The first major problem with the Runtime.exec() method is that path is obviously a variable and would need to be placed outside the quote marks: Process p = Runtime.exec("set classpath=" + path); Secondly this would only work under Windows, in Unix/BASH the command to set an environment variable would be export CLASSPATH=path.
    I had a similar problem two years ago, unfortunately I can't remember exactly how I did it, but I'm fairly certain it involved using the system properties of the System class. There is a system property called java.class.path, more info can be found in the API for the System class: http://java.sun.com/j2se/1.4.2/docs/api/java/lang/System.html
    Look especially at the methods getProperties() (contains a list of the system property names), and setProperty().

  • Setting Classpath in linux

    Hi !! Can anyone help me in setting classpath in linux to run servlets/? I tried using this command..but didnt work
    export CLASSPATH="$CLASSPATH:/usr/share/tomcat5/server/lib/servlets-common.jar"
    Thanks
    Nive

    in ur autoexec.bat file write the following
    set PATH=C:\jdk1.5.0_04\bin;%PATH%
    set JAVA_HOME=C:\jdk1.5.0_04
    set
    CLASSPATH=.;C:\jakarta-tomcat-5.5.9\common\lib\servlet
    -api.jar;C:\jakarta-tomcat-5.5.9\common\lib\jsp-api.ja
    r;C:\Servlets+JSP;..;..\..;C:\jakarta-struts-1.2.4\lib
    \struts.jarThis response is meaningless. Principally because the OP specifically mentioned the use of LINUX. Not Windows.
    I've taken the advice of other forum users by avoiding a system level classpath variable. I define the classpath each time I compile and run. Working on Linux I tend to use command line argument files ( http://java.sun.com/j2se/1.5.0/docs/tooldocs/solaris/javac.html#commandlineargfile ) which eliminates the need to redefine the classpath each time I compile or run my classes and apps. But others may do things differently.
    Here is a website you might want to check out which pertains to setting the classpath on Solaris and Linux.
    http://java.sun.com/j2se/1.5.0/docs/tooldocs/solaris/classpath.html

  • Package does not exist even though I set classpath right!

    Hi, my JSP got an error message saying "Package does not exist" at line
    <% import ="org.jfreechart.*"%>
    And I have put the myjar.jar file containing the above classes into blabla\WEB-INF\classes,(where blabla is my current working directory) and set my classpath= blabla\WEB-INF\classes
    It does not either if set classpath= blabla\WEB-INF\classes\myjar.jar
    Anybody could give suggestion? By the way I am using Tomcat.

    your .jar files should be in WEB-INF/lib

  • Help with setting classpath

    Hi All,
    I am new to servlets and JSP. I have a question regarding setting Classpath. My development directory structure is like this c:\..\desktop\java\project1\src\com\eg\web\e1.java. Servlet.jar file is in C:\Program Files\Apache Group\Tomcat 4.1\common\lib. I tried setting Classpath in windows 2000 using control panel=>System utility by this command
    SET CLASSPATH=.;c:\Program Files\Apache Group\Tomcat 4.1\common\lib\servlet.jar . I try to compile my program by going into the whole development directory structure C:\..\src\com\eg\web using javac e1.java. But I get the error "package javax.servlet does not exist". Can somebody help me resolve this?
    Thank You in advance
    Jaya

    Question 1: Are you using an IDE?
    [IDEs ignore the system classpath]
    Question 2: Did you try setting the classpath using the -cp option for javac, if you are not using an IDE?
    [you could also try to print the classpath on command line to check if it has taken effect]

Maybe you are looking for