Problems setting classpath...

hello guys...i am having a problem with what should be a very simple operation...
the classes i define are stored in the classes directory..inside, each package has its own subdirectory...
classes
beans
User.class
Cart.class
i have tried to change my classpath to reflect this location and instruct the compiler as to where to find those classes..
i have used the set Classpath command...
SET CLASSPATH=.;C:\Tomcat\common\lib\servlet-api.jar;C:\Tomcat\common\lib\mysql-connector-java-3.1.13-bin.jar;
C:\Tomcat\webapps\theagent\WEB-INF\classes beans.User;
but when i try to import beans.User in another class..it doesnt compile and tells me that the package doesnt exist...
please help....what else do i need to check to make sure the configuration is as it should be...
p.c User.java started with package beans;
thanks

That is correct because your beans.User class doesn't contain a
public static void main(String[] args) method, iow you can't run it by itself.i dont want to run the class by itself... i just want to import beans.User;
but it says that no such package exists...Then you have to be a bit more clear. You mentioned this command line:java -classpath C:\Tomcat\common\lib\servlet-api.jar;
C:\Tomcat\common\lib\mysql-connector-java-3.1.13-bin.jar;
C:\Tomcat\webapps\theagent\WEB-INF\classes beans.User;This sets the classpath pointing to two jars and a 'classes' directory.
You're trying to run the 'beans.User' class which I presume is stored
in a subdirectory of that 'classes' directory.
The java command works like this:java -classpath <jars and dirs here> package.YourClass... so you were trying to run your beans.User class all by itself. It doesn't
contain a main method hence the runtime diagnostic. btw, I don't know
why you appeded that whole thing with a semicolon.
kind regards,
Jos

Similar Messages

  • Problems in setting classpath in vista

    i am using Xp pro and Vista.
    My issue is that I am not able to set classpath in vista.
    i want to set classpath so that I can compile and run programs from different folder other than default one in which java is installed.
    Please help.

    i am using Xp pro and Vista.
    My issue is that I am not able to set classpath in
    vista.
    Don't worry about it. The CLASSPATH variable is best avoided anyway. Specify classpaths for particular apps on the command-line. Teh Docs show you how
    i want to set classpath so that I can compile and run
    programs from different folder other than default one
    in which java is installed.
    Please help.This suggests you're talking about PATH rather than classpath. Do you understand the difference?

  • Problems setting up JDBC

    I recently downloaded mysql Connector for my project.
    However, I have problems setting it up.
    When I run my program, It gives me a class not defined error.
    System.out.println("Registering Driver...");
                   Class.forName("com.mysql.jdbc.Driver").newInstance();
    System.out.println("Connected to database");
    System.out.println("Creating Connection");
    connection= DriverManager.getConnection("jdbc:mysql://localhost:8080/neuis");
    System.out.println("Connection created");
    catch(Exception ex)
    System.out.println("Error in loading jdbc Driver: "+ex);
    ex.printStackTrace();
    I have put the jar file of the JDBC Bridge in a folder
    C:\Drivers\Sql Connector
    I have also added the absolute path of the jar to the system classpath
    The value put in is:
    C:\Drivers\Sql Connector\mysql-connector-java-3.1.10-bin.jar.
    I am not sure what the problem is because I was told by the API that this was all I needed to do. Are there any other files I need to include with the jar file? Also, Is there a specific folder I must put it in?
    Thank you in advance.

    Hi,
    Take a look at the below link
    http://www.cs.nott.ac.uk/TSG/manuals/databases/mysql/jdbc.html
    may help you to setting up the jdbc with mysql
    regards
    MJ

  • Trouble Setting Classpath on Windows XP

    I'm having trouble setting up a classpath on Windows XP for SDK1.3.1_04.
    I've tried Control Panel\Advanced\Environment Variables\System Variables. There was a Path variable present, to which I've added:
    c:\jdk1.3.1_04\bin;
    There wasn't a Classpath variable present though. I've tried adding it myself in System Variables as follows:
    Variable name: Classpath
    Variable value: set classpath=.;
    But no joy. When I run "set" from the command prompt, there's no classpath present.
    I'd appreciate any help.
    Cheers.

    Hi,
    I am running on XP (unfortunately), but also win2000 and win98.
    Setting up the classpath is not a problem, although if you are logged in as root, then it does not always show correctly.
    Try logging back in as yourself and then checking the classpah through the set command.
    Altrnatively, if this is not the problem, actualy try a reboot. which should not be necessary.
    best
    kev

  • How to Set CLASSPATH in Apache Web Server Using IAS

    Hi,
    I have problem setting the classpath for the servlet I am using for file uploading...My work environment is Web Server is Apache with Oracle8i IAS on Sun Solaris..
    I have tried various method like setting wrapper.classpath=/oracle/ias/Apache/Jserv/servlets and my class resides under /oracle/ias/Apache/Jserv/servlets/com/oreilly/servlets/MultipartRequest.class
    in the Jserv.properties, still it get the error message class ...not found in type declaration when I compile the code...my reference to the servlet in my JSP code is com.oreilly.servlet.MultipartRequest ..
    Can someone help me out please, if you have have any idea of how to set the class path with the working environment I have specified ealier....
    null

    have you posted this on the ias 9i forum where the ias 9i apache experts are at ??

  • Problem of classpath

    Hi,
    I have to face a very stupid problem I can't fix by myself.
    I run under Windows Me and I had a few minutes ago to add some .jar files to my classpath.
    I don't know what error I did during this tranformation, but now, every time I open a Dos-window, after the path of the current folder, there is a ; I can't absolutely not remove.
    By the way, every time I open a Dos-window, a .temp file appears in my c:\ directory too, something that did not happen before.
    Here's my autoexec.bat file:
    SET COMSPEC=C:\WINDOWS\COMMAND.COM
    SET windir=C:\WINDOWS
    SET winbootdir=C:\WINDOWS
    SET PATH=C:\WINDOWS;C:\WINDOWS\COMMAND;c:\jdk1.3\bin
    SET CLASSPATH=C:\tomcat\common\lib\servlet.jar;C:\xalan\bin\xalan.jar;C:\xalan\bin\xercesImpl.jar;C:\xalan\bin\xml-apis.jar;C:\xalan\bin\xalansamples.jar;C:\xalan\bin\xalanservlet.jar;C:\xalan\bin\bsf.jar;C:\xalan\bin\js.jar;c:\xalan\samples\ApplyXPath;C:\fop\build\fop.jar;C:\fop\lib\avalon-framework-4.0.jar;c:\fop\lib\xalanj1compat.jar;c:\fop\lib\batik.jar;c:\fop\lib\ant.jar;c:\fop\lib\logkit-1.0.jar;c:\java;c:\soap-2_2\lib\soap.jar;.;C:\jdk1.3\lib\tools.jar;c:\tomcat\common\lib\mail.jar;c:\tomcat\common\;C:\Mes_documents\XML\semanticWeb\Jena\bis\Jena-1.4.0\lib\jena.jar
    SET JAVA_HOME=c:\jdk1.3
    SET CATALINA_HOME=C:\tomcat
    SET PROMPT=$p$g
    SET TEMP=C:\WINDOWS\TEMP
    Thanks a lot for helping me,
    Steevy.

    Please, it's very urgent, I'm completely locked with this difficulty.
    DId anybody face the same problem?
    The question is:
    What can be the cause of having automticcaly a ; in a DOs-Window when we open it?
    Thanks for your answers,
    Steevy.

  • 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 does not work, how do I run java.exe?

    Hi guys,
    I have a problem running the java.exe and I'm using Win XP. Here is my problem:
    Under the command prompt, I set the path: path = C:\Program Files\Java 2\j2sdk1.4.2_05\bin
    Then I created a folder in E:\Hello. I save my Hello.java in that folder, and I compiled it:
    javac Hello.java
    Now, there is a Hello.class created in that folder.
    Then I try to run it: java Hello
    but I got an error: "Exception in thread "main" java.lang.NoClassDefFoundError: Hello"
    So, I try to set CLASSPATH, however, the problem remains, no matter how hard I try.
    Any ideas?

    None of the suggestion worked, I wonder why???
    Here is my location for the JDK:
    C:\Program Files\Java 2\j2sdk1.4.2_05\bin
    Here is my location for my Java project file:
    E:\JavaProject\Hello
    Here is the file name:
    Hello.java
    Here is the command prompt:
    C:\Documents and Settings\Alex Ngai> e:
    E:\> cd JavaProject
    E:\JavaProject> cd Hello
    E:\JavaProject\Hello> path = C:\Program Files\Java
    2\j2sdk1.4.2_05\bin
    E:\JavaProject\Hello> javac Hello.java
    E:\JavaProject\Hello> java Hello
    Exception in thread "main"
    java.lang.NoClassDefFoundError: Hello
    E:\JavaProject\Hello> java -cp Hello
    // Does not work, it lists all of the options for java
    E:\JavaProject\Hello> set CLASSPATH =
    E:\JavaProject\Hello
    CLASSPATH="C:\Program
    Files\Java\j2re1.4.2_04\lib\ext\QTJava.zip"
    E:\JavaProject\Hello> java Hello
    Exception in thread "main"
    java.lang.NoClassDefFoundError: Hello
    // I have tried a lot more, none of them won't work!!
    Now what should I try in the following command prompt?
    E:\JavaProject\Hello>Given the above there is only one possible explaination.
    You have a file named "Hello.java".
    In that file you have a non-public class which is NOT named "Hello". Instead it is named something like "HelloWorld" or even "hello" (case matters.)

  • Can't compile Servlet program(error in setting classpath in XP)

    I encountered a similar problem as 'hereispaddy'.
    "I have recently written a servlet program. When I compile the program (let's say "HelloWorld.java"), I've got the following error message:
    package javax.servlet does not exist
    I've download the class files and set the classpath already. Have I missed anything? "
    i would like to ask, how to set the following in Windows XP:
    set CATALINE_HOME=C:\PROGRA~1\APACHE~1.0
    set CLASSPATH=.;%CATALINE_HOME%\COMMON\LIB\SERVLET.JAR;C:\JDK1.4\BIN;
    *ive tried in control panel->system->advanced->environment variables->
    variable name:CATALINE_HOME
    variable value:C:\Program Files\Apache Tomcat4.0 (and)
    variable name:CLASSPATH
    variable value:.;%CATALINE_HOME%\common\lib\servlet.jar;C:\jdk1.4\bin
    but failed!
    Could anyone kindly tell me what's wrong with my setting?
    Thx a lot!!!

    Does Tomcat work? Can run the examples on the home page?
    The only suggestion I have at this point is to get rid of the spaces in
    C:\Program Files\Apache Tomcat4.0
    But I am still in Win98 , so I am just guessing.

  • Setting CLASSPATH's on Windows & Linux

    I am still new Java programming language, but I am coming along in learning the actually language. The one problem I keep running into is how to set a CLASSPATH on a windows machine and Linux machine. I have currently installed j2sdk1.4.2 on the windows machine and jdk1.5.0 on the linux machine. If any one has any suggestions on how to set these CLASSPATH's I would greatly appreicate it.

    Before ammending classpath I recommend checking the
    windows path variable. This variable is a list of
    folders where windows looks for executables.
    Path can be viewed by going to control panel ->
    system _> advanced table -> environmental variables
    and then selecting path and then edit.
    Make sure �C:\Program Files\Java\J2SDK1.5.0\bin� (or
    equivalent)is included.
    Alternative you can enter �path = %path%; �C:\Program
    Files\Java\J2SDK1.5.0\bin� into command prompt each
    session.
    This ensures that you can compile and execute java
    programs from any directory. Ideally the java
    installer should do it but I have found it does not.Indeed.
    Similarly the classpath can be varied from either the
    command prompt or it can be added to the
    environmental variables.I'm one of those that recommends folks not set CLASSPATH using an environment variable.
    IDEs like Eclipse and IntelliJ totally ignore it; so do containers like WebLogic and Tomcat.
    One CLASSPATH does not fit all. Every project is unique. The best way to set it is with the -classpath option on both javac.exe and java.exe.
    For compiling, you should learn Ant. It's a make tool built on Java and XML. That'll help with your compilation issues.
    For running, you'll either run in a container, which has its own idea of CLASSPATH, or you can script the startup of a batch job using a Windows .cmd or *nix .sh.  Set the CLASSPATH in the script.
    If altering it from the command prompt, in windows
    use a �;� between paths variables and a �:� for unix
    systems. Also include a �.� as one of the path
    variable as it includes the pre-existing class path.
    For example, when entered from the command prompt (in
    windows), the following line will add �C:\
    JavaPrograms� to the existing Classpath
    Java �cp .;C:\JavaPrograms
    Alternatively go into environmental variables as
    described above and if a classpath variable does not
    exist, create one and include �.� and your desired
    directory.
    Note: I prefer adding directories to the classpath
    via the environment variables as it is more accepting
    a folders with spaces in the name.Installing software in a folder with spaces in its name is asking for trouble. It's not highly recommended.
    %

  • Setting classpath within java application

    Hi
    Sorry if this question has already been asked, I've searched for it but couldn't find it.
    I've written a class (see below) that when given a directory will add all of the jar files to the classpath.
    The classpath is updated to include all of the jar files but if I try to use a class within one of these jar files then an exception is generated stating that the class can't be found.
    Can anyone help me with this problem? I thought that I would only need to update the classpath.
    Thanks,
    Rob
    public class Jar {
         public static void addJarsToClasspath(String root) {
              File f = new File(root);
              if (f.exists()) {
                   File[] jars = f.listFiles(new FilenameFilter(){
                        public boolean accept(File dir, String file) {
                             return ((String)dir.getName()+file).endsWith(".jar");
                   String classpath = System.getProperty("java.class.path");
                   for (int i=0; i<jars.length; i++) {
                             classpath = classpath.concat(":"+root+"/"+jars.getName());
                   System.setProperty("java.class.path",classpath);
                   System.out.println(System.getProperty("java.class.path"));

    You can do this with batch files in Windows NT/2000:
    1) create a batch file called "setcp.bat" containing the following:
    for %%i in (C:\myPath\*.jar) do call appendcp.bat %%i
    2) create another batch file called "appendcp.bat" containing the following:
    set CLASSPATH=%CLASSPATH%;%1
    Now you can run setcp.bat and it will add all JAR files in C:\myPath to your CLASSPATH.
    Jesper

  • Problems using classpath

    Hi !
    I'm using java on win98.
    I'm trying to modify class path and source path.
    I was told to write:
    set CLATHPATH=path1;path2
    and then compile by:
    javac -d classes sources\path
    when trying to do it it says:
    the classes directory does not exit.
    what is the problem ?
    Thank you

    Hi !
    I'm using java on win98.
    I'm trying to modify class path and source path.
    I was told to write:
    set CLATHPATH=path1;path2
    and then compile by:
    javac -d classes sources\path
    when trying to do it it says:
    the classes directory does not exit.
    what is the problem ?
    Thank you
    it should read:
    set CLASSPATH=path1;path2
    where path1 and path2 are valid paths to be used in locating classes for execution. As an example you might use something like:
    set CLASSPATH=.;c:\;d:\;c:\javaclasses
    Regards,
    Mark

  • 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().

  • Set Classpath at runtime

    Hi everybody! I'm using NetBeans IDE 3.6 and I want to change the classpath at runtime. I�ve tried to make:
    set classpath="C:\Documents and Settings\Koening\Mis documentos\Proyectos";but it doesn�t recognize that sentence. If anybody knows how to change it at runtime please answer me.
    Thanks for the replies!!!

    I assume you were talking about a .bat file as you're writing that more or less in .bat format. The main problem if that's the case, is that you're not supposed to put quotes around the value:
    set classpath=C:\Documents and Settings\Koening\Mis documentos\Proyectos
    Actually changing the classpath at "runtime" (i.e., after the JVM is started) is more involved, and normally requires writing a launcher class which does nothing but create a URLClassLoader with the appropriate URLs, fetch the real main class from the new classloader, and executes its main method.

  • Setting Classpath and Path on Windows ME

    Hi..How do I set up the classpath and path on windows ME. Do I use DOS or run the autoexec.bat from windows directly. I have jdk1.3.1 abd my classpath and path are:
    set classpath="C:\jdk1.3.1\bin"
    set PATH=C:\windows\xxxx\;C:\jdk1.3.1\bin
    I sometimes can't compile my programs from other directories other than jdk1.3.1\bin. Why? Is there a way I can compile my program just from the C:\ directory like:
    C:\javac myprogram.java
    C:\java myprogram
    Thanks.

    If you put . in the beginning of your classpath, java always searches the folder you are currently in.
    Now to set the classpath try clicking from the startmenu:
    settings/control panel/system. Then click advanced tab and then the Enviroment variables. I'm on win2000 but I think it should be the same on ME.
    Make sure it starts with .;C:\jdk1.3.1\bin;....
    I think installing jdk puts in the essentials, but if you have certain folders you store your classes in you can stick those in there as well.
    If you hava more questions about this, I suggest searching these forums on Keywords like : "set CLASSPATH PATH". Then you'll find a bunch of threads solving this problem.
    Sjur

Maybe you are looking for

  • CS3 not opening .CR2 files

    I can't get either Photoshop or Bridge to recognize/open .cr2 files. I have Camera Raw pug-in 4.6 installed, fully updated CS3, Snow Leopard 10.6.4 and the pictures are taken with an EOS 7D. Can't get my head around what's going on here. The funny th

  • JTabbed pane obscures text

    I have made five tabs. Some are behind others by default. The text on the tabs behind the front tabs are obsured in the Windows L&F. It is much worse in the Motif L&F. However it is fine in the Metal L&F. Is there a way of making the behind tabs sit

  • Custom Connector Deployment : java.lang.NoClassDefFoundError

    Hi, We have a Custom Connector for connecting to the Google System. I moved the Objects from an existing OIM System to the new one. Now, I have the following error thrown when the "Create User" Task is getting executed. Is there a way to print which

  • Lightroom 1.3 catalog shows Photoshop application folders (OS X Leopard)

    Hi, I have been using Lighroom without problems for a long time but now I got this weird problem with Lightroom (I am using OS X Leopard & Lightroom 1.3) Few days ago just in the middle of using lightroom tens of new folders appeared to the catalog.

  • SOAP: need help with executeXMLQuery

    Hi all, I'm using OBIEE Webservices to retrieve report results from a .net web application. Everything works fine except that the XML returned is not the final result of the report but the initial fields used for calculating the reports, ie. no aggeg