A classpath question

Hi everybody,
I have classpath set and can run a Java code but can not compile the same code:
The code calendar.java is under: /home/Java
/home/IdeaProjects/dir/src>java -classpath /home/Java:. calendar
// Runs the code
/home/IdeaProjects/dir/src>javac -classpath /home/Java:. calendar.java
error: cannot read: calendar.java
1 error
Any idea? Any help is greatly appreciated.

"cannot read" doesn't sound like a classpath problem, it sounds like a file system issue, completely independent of javac.
-classpath for javac does NOT tell it to look in those directories for the java files listed. It just means to look there for classes it needs.
You still need to give it a full or relative path to where the .java files are. If you just give it foo.java, it will try to look in the current directory.
-sourcepath may also work. I never use it. The one time I tried it didn't seem to work the way I expected so I dropped it. I'm not sure exactly what it's for or how to use it.

Similar Messages

  • Manifest Classpath Question oc4j.jar

    I need some clarification on how the MANIFEST.MF in the oc4j.jar library is influencing classlading. Below are my specific questions:
    My group is using a configuration management tool which stores all java libraries in a central repository. During builds the tool downloads all dependent libraries in basically a flat directory format and specifies a classpath to java when it runs its builds (and starts up OC4J via java com.evermind.server.OC4JServer). Is there anyway to override the Manifest.MF with the classpath constructed by our configuration management tool?
    In many cases libraries are entered in twice but are from different locations. i.e.
    ../../lib/xmlparserv2.jar
    ../../oracle/lib/xmlparserv2.jar
    Is there a difference between these two libraries?
    In the classloading sequence when does the classloader refer to the Manifest.MF for locations of libraries?
    Thanks in advance!
    -Mark

    Hi Mark,
    I'm sure I haven't understood your question, so the following may be useless to you (please excuse me if it is).
    I feel there is probably a better way to do what you are trying to do, but without more details, I can only guess.
    Do you know about the java extension mechanism?
    The tooldocs Web page has details of how the JVM locates classes.
    There are also some whitepapers and other documents that you can access from the OC4J home page at Oracle's Technet Web site.
    Good Luck,
    Avi.

  • Fundamental j2ee classpath question

    hi folks --
    I have a j2ee project with
    - a WAR (which has among other things a servlet in it)
    - a ejb project (which has a stateless session bean in it)
    I need to call the session bean from the servlet and my servlet code gets a reference to the bean via jndi as follows
    ...skipping jndi stuff ...
    LoadTimerTaskHome loadTimerTaskHome = (LoadTimerTaskHome)PortableRemoteObject.narrow( timerHomeObject, LoadTimerTaskHome.class);
    However, at compile time, LoadTimerTaskHome (the home interface of the bean) can't be resolved in the servlet class. Which makes sense cuz how would the servlet class know about the bean class?
    And that's the question: At compile time, how can i make classes in my WAR aware of classes in my EJB proj, which are deployed to the same EAR? There must be a very simple J2EE way of doing this...
    I'm not an EJB person, so i'm just confused about what is probably extremely basic....
    thx VERY much for any insights...

    A brute force approach is to also package the ejb interface classes (and any classes needed by those interfaces etc.) in the .war. However, a cleaner solution is to put the shared classes within a utility .jar and package it within the .ear such they are visible by both .war and ejb-jar modules.
    In Java EE 5, this is easily done by putting the shared .jar in "lib" directory at the top-level of the .ear. Java EE 5 guarantees that any .jars within that directory are visible to all component modules within the .ear.
    Prior to Java EE 5, this was only possible by using the MANIFEST-CLASSPATH attribute within each module to refer to the utility .jar. That's very cumbersome and error-prone so I recommend the automatic "lib" directory approach.
    --ken                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Apache Commons Net deployment fails to resolve, JDev classpath question

    I wrote a wrapper to apache's most recent version of commons-net package (version 1.4.1) to allow me to execute FTP services from an Oracle 9i2 database. After adding the common-net .jar file to the JDev libraries, and including this library in my project, I debugged the code in Jdeveloper, then deployed to the Oracle 9i2 server. However, many classes of the of the common-net (and my code) failed to resolve in the database.
    After downloading open source product DependencyFinder, and running against the Commons-net .jar file, I found that some packages were dependent on the Apache ORO regexp package. The ORO package, as far as I can tell, is not in any classpath that my JDev project uses. There is listed in the JDev libraries, a library called Apache Regexp, but I did not include that in the project, either.
    After I downloaded the ORO package from Apache, added it to JDev's libraries, included it in my project, and added the ORO library to the list of classes to deploy (using the loadjava deployment profile), deployment to Oracle 9i2 of the my classes, the commons-net classes, and the ORO classes properly resolved.
    My question is: Why did my application work under JDeveloper? How and where did it find the ORO classes?
    The version of Java under which JDeveloper is running, and the version being used as the compiler for this project, is a new installation of JDK1.4.2_10.

    Since the commons net 1.4.1 is compatible with jdk 1.3.1, I should only need to use loadjava on the .jar file. In fact, that works, given that there is no failure on load due to incompatible .jar or .class files structure.
    But, I've just solved this part of the problem. The commons net 1.4.1 is dependent on, but does not include the Apache ORO library. Once the ORO library was deployed to Oracle 9i2, all common net 1.4.1 classes were resolved.
    The "problem" is with JDeveloper. Without including the ORO library in the JDeveloper application, or in the classpath, it worked under JDeveloper -- the more surprising since I had never downloaded the ORO library from Apache. Only after downloading ORO, explicitly defining ORO to JDeveloper, and including ORO as a library in my JDeveloper project, did the deployment of the application to Oracle 9i2 succeed (though the application always executed successfully under JDeveloper).

  • EJB Classpath Question

    Hi,
    I have a burning question regarding EJBs and classpaths.
    Here is my situation:
    - My application uses EJBs, Servlets and JSP pages
    - My EJB remote interfaces and implementation classes extend common,
    abstract base classes
    - My EJB implementation classes use several utility classes, which are
    also used by my servlets.
    - Each EJB is deployed in a separate JAR file
    The question I have is which classes should be included in the EJB JAR
    files.
    I'd like to put just the EJB implementation class in the EJB JAR, and
    put everything else in a common JAR that is placed in my WEB-INF/lib
    folder and shared by the rest of the application. However, if I do
    that, Weblogic won't load the EJBs because it tries to do so before it
    deploys my web app, and hence before it adds the JARs in the
    WEB-INF/lib folder to its classpath.
    I can explicitly add my jar to the Weblogic classpath on the
    commandline (weblogic.class.path property). Now my EJBs load. However,
    my servlets become unable to load any classes from any jar in
    WEB-INF/lib. I read something about it being a bad idea to include a
    jar from WEB-INF/lib in the classpath, so I'm probably seeing that
    problem.
    The third option is to include all the dependent classes in my EJB
    jars themselves, in addition to deploying them in WEB-INF/lib. This
    works, but it bothers me that there are multiple copies of the same
    class files lying around.
    I'm sure I'm not the first developer who's written an EJB that shares
    classes with a servlet or JSP page. What's the proper way to do this?
    Thanks.

    Use a ClassPath entry in your EJB jar module MANIFEST.MF file
    Mark Cordobal
    [email protected] (Frank LaRosa) wrote:
    Hi,
    I have a burning question regarding EJBs and classpaths.
    Here is my situation:
    - My application uses EJBs, Servlets and JSP pages
    - My EJB remote interfaces and implementation classes extend common,
    abstract base classes
    - My EJB implementation classes use several utility classes, which are
    also used by my servlets.
    - Each EJB is deployed in a separate JAR file
    The question I have is which classes should be included in the EJB JAR
    files.
    I'd like to put just the EJB implementation class in the EJB JAR, and
    put everything else in a common JAR that is placed in my WEB-INF/lib
    folder and shared by the rest of the application. However, if I do
    that, Weblogic won't load the EJBs because it tries to do so before it
    deploys my web app, and hence before it adds the JARs in the
    WEB-INF/lib folder to its classpath.
    I can explicitly add my jar to the Weblogic classpath on the
    commandline (weblogic.class.path property). Now my EJBs load. However,
    my servlets become unable to load any classes from any jar in
    WEB-INF/lib. I read something about it being a bad idea to include a
    jar from WEB-INF/lib in the classpath, so I'm probably seeing that
    problem.
    The third option is to include all the dependent classes in my EJB
    jars themselves, in addition to deploying them in WEB-INF/lib. This
    works, but it bothers me that there are multiple copies of the same
    class files lying around.
    I'm sure I'm not the first developer who's written an EJB that shares
    classes with a servlet or JSP page. What's the proper way to do this?
    Thanks.

  • Classpath question about the " . " notation

    I try to run the class file from the /a/b/c/d directory using classpath:
    java -classpath . MainClass
    But so far this doesn't work. My current directory is /d which is the same as MainClass is in, and I use the " . " notation in -classpath to indicate a search in the current directory, and if I use the " . " then the full name of the class is not required (since I am in the same directory). But I know I am using classpath correctly because in my other try this works:
    java -classpath /a b.c.d.MainClass, when my current directory is /a.
    Thanks for any ideas.
    My directory structure is as follows:
    a
    b
    c
    d
    MainClass.class
    package b.c.d;
    public class MainClass {
      public static void main(String[] args) {
    System.out.println("Test");
    }

    So, basically no matter where I tell the classpath to look for a class, or what is my current directory I have to *always" include the full-qualified name for the class? Is that correct? I couldn't find that specific piece of information in the java tutorials...                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Setting CLASSPATH question

    Hi,
              I'm evaluating Weblogic 5.1. My evaluation requires me to write an
              Enterprise Java Bean that uses Container Managed Persistence, place it on a
              server, and have an HTML page call into the EJB through a servlet. The
              servlet is also sitting on the server. I've managed to prove that this
              works within the confines of Visual Cafe EE, but cannot make it work
              independantly.
              I've set my HTML page to have a link to the servlet I need to hit
              (http://Local IP:7001/ServletName). The EJB is properly deployed. The
              servlet is registered in weblogic.properties. But when I hit my link, it
              returns a "10.5.1.500 Internal Server Error". And the server throws a
              ServletException which tells me that "Servlet class:
              weblogic.servlet.ServletName could not be loaded - the requested class
              wasn't found in classpath."
              "weblogic.servlet.ServletName" is my location on the server. I've
              registered that location in my wl.props and it shows on the server. I'm
              running Win2K and have the location of my EJB and location of the servlet in
              both the User CLASSPATH and the System CLASSPATH.
              Can anyone help me out? Where can I find the exact meaning of error
              "10.5.1.500 Internal Server Error"?
              Feel free to contact me at [email protected] or directly at 303-987-3499
              ext-35.
              Thanks, 'Soli
              

    [email protected] (Chris Basoli) wrote in
              <[email protected]>:
              >Hi,
              >"weblogic.servlet.ServletName" is my location on the server. I've
              >registered that location in my wl.props and it shows on the server. I'm
              >running Win2K and have the location of my EJB and location of the
              >servlet in both the User CLASSPATH and the System CLASSPATH.
              I'm having a little trouble understanding "my location on the server". The
              registration is for associating names with classfiles. Thus, in order for
              what it seems like you're saying here to work, you'd need (assuming a
              default installation of WLS):
              in weblogic.properties:
              weblogic.httpd.servlet.classpath=c:/weblogic/myserver/servletclasses
              weblogic.httpd.register.ServletName=weblogic.servlet.ServletName
              on the filesystem:
              c:\weblogic\myserver\servletclasses\weblogic\servlet\ServletName.class
              >
              >Can anyone help me out? Where can I find the exact meaning of error
              >"10.5.1.500 Internal Server Error"?
              From this error, I can determine that you do have the register part of the
              properties file properly set up. Either the class file is not there (see
              filesystem statement) or it does not have the proper package statement.
              The error is actually "500 Internal Server Error". The 10.5.1 might be a
              documentation reference (Cameron? BEA?), but the 500 error is sufficient.
              It means the web server you're talking to had a processing error that it
              couldn't recover from and thus could not return the response you requested.
              You'll usually get in in servlet failures, or app server failures.
              Jesse
              

  • Another classpath question

    Hi,
    I used to programm in java but then I took a break because of school issues for a long time. Now it seems like Ive forgotten everything.
    Well I installed java again (because reinstalled windows meanwhile) and I successfully set my PATH variable, which means that compiling of *.java files works easily.
    But now I have the problem of running my *.class file. If I type "java HellloWorldApp" (like written in the tutorial) I get the error:
    "Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorldApp "
    It says in tutorial to try "set CLASSPATH=" which I did and it worked. But now I want to have that permanently. So what should I do? Should I change the CLASSPATH enviroment variable to an empty value in windows xp?
    thanx
    UsulSK
    P.S.
    It also sais in the tutorial about that problem: "For more information, consult the section 5. Update the PATH variable in the installation instructions.". I went there but there is nothing written about that problem and it is only explained how to set the PATH variable which I already managed to do.

    CLASSPATH denotes the path for searching your class files. So obviously it cannot be set to empty :)
    Since yours is WinXP, to set CP permanently, rightclick on My Computer and click on Properties. Choose Advanced tab and click on Environment variables. There you will find CLASSPATH. Click on Edit button to modify the path. Leave the path you see as it is and then append it with the following path of your lib directory
    c:\<java_install_dir>\lib
    where C: is the drive where your java is installed. If you are doing your programs on a different directory such as C:\UsulSK\Java, you can include the same in the classpath. Always separate different paths with semi colon.
    Click on OK to confirm the modification. The new classpath takes into effect when u open a new cmd prompt window... .
    HTH
    PS: Read material on setting classpath from sun website

  • Quick, Easy classpath question

    I thought I understood classpaths, but I encountered an error I could not explain.
    I have my classpath set to:
    C:\Project1;C:\Project2
    Note that these folders are not packages themselves, but are the root folders containing all the package folders and class files.
    One class contained inside of a package in Project2 imports and uses a class contained inside of package in Project1. I am getting a NoClassDef found error. I could have sworn that this has worked before.
    Can someone set me straight on how I need to set this up?
    Thanks in advance,
    hqd

    Hi Friend,
    At run time it is possible to set the class path.
    Use the following option with �Java�
    $java �classpath .;C:\Project1;C:\Project2
    It may help you
    Have a nice day
    Ajomon Mathew

  • Applet classpath question

    I have my applet "applet.class" in my directory "." along with the html page.
    so, codebase=. code="applet.class"
    This class is in a package: this/is/my/pkg
    so we have this/is/my/pkg/applet.class
    I get an exception stating: ClassNotFound applet.class(wrong name: this.is.my.pkg.applet.class
    I have my html page and my applet.class in the pkg directory, so I use "." as code base, right?
    Well I try changing applet.class to this.is.my.pkg.applet.class like the exception says to and I get ClassNotFound again, but without the wrong name part.
    This will only work if I do this:
    codebase=../../../.. code="this/is/my/pkg/applet.class
    WHY?

    Package assumes a directory structure. So when your class is compiled it has to be in the pkg folder, int the my folder etc. (this/is/my/pkg)
    You still have to maintain the folder structure and put the html at the root of the this folder.

  • How can i set the classpath??

    CAN ANYONE PLEASE HELP ME HOW TO SET THE CLASSPATH IN WINDOWS ME ,WHAT IS THE RIGHT CODE TO SET THE CLASSPATH I AM USING JDK1.3 VERSION.
    THANK YOU VERY MUCH
    ERICK LUCCIO

    Try this way Start->Program->System tools-> System Summary>startup .Try to find the variable classpath,make sure the path is correct.The classpath contain the the *.java & *.class you save. I'm also new in java .This path & classpath question is so trouble to me .Now i'm running jdk1.3.1_2 in WINME ,WINNT AND WIN2000 IN no problem.........

  • 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]

  • What are the most common questions in the forums?

    I have my own ideas about what are the questions we see asked over and over and over again in here. Everyone post your ideas here so we can compile a FAQ and maybe post it somewhere (Virum, your new site? :) )

    Please do my homework/coursework/think for me
    This has to be by far the most common type of question asked on the forums.
    Classpath questions
    HashCode questions
    Pointer vs Reference Debate (totally spurious but people spew 100's of pages arguing about something that is perfectly obvious)
    A very good Thread that is probably 1000's of entries long by now is the
    "How to get your questions answered promptly" one (or however this is called). A recap of that published somewhere would be of tremendous value, especially if it was presented as a page you had to go through before landing in the forums to post your latest "Java Challenge" aka "do my coursework" on the boards.

  • Dont want to hard code the -Djava.class.path...notation question

    Hello everyone,
    I have a c++ program that is compiled into a DLL file. It calls the JNI_CreateJavaVM. I have the whole thing working but now I need to port it and the jar file to another machine.
    right now i am setting the options this way:
    #define USER_CLASSPATH "c:\\javaClasses\\intec.jar.zip" /* where PRLocalBridge.class is */
    #define PRCLASS "com/intec/intecapi/PRLocalBridge"
    bool PRLocalBridgeMain(){
         JavaVMOption options[1];
         options[0].optionString = "-Djava.class.path=" USER_CLASSPATH;
         vm_args.version = JNI_VERSION_1_4;//0x00010002;
         vm_args.options = options;
         vm_args.nOptions = 0;
         vm_args.ignoreUnrecognized = JNI_TRUE;
        /* Create the Java VM */
        res = JNI_CreateJavaVM(&jvm, (void**)&env,&vm_args);
        if (res < 0) {
         return (bool*)errorHandler('b', CANT_INVOKE_JVM);
        cls = env->FindClass(PRCLASS);
    }where USER_CLASSPATH is hardcoded directly to where the jar
    file is located. in other machines, it may not be loaded
    in that file structure. how do i softcode the path?
    ive put the jar in my classpath but that doesnt seem to work
    (unless i didnt have USER_CLASSPATH set properly). Thanks
    in advance :)
    txjump

    hi bschauwe,
    thanks for the suggestions! i was hoping you would reply. You have helped some others with classpath questions. :)
    since its a dll, can you pass it values?
    we do have an ini file that is already created but the file parser is in java so i would have to write another one in c. id like to stay away from that though. cause if it gets messed up or goes missing, clients wont be able to reach the java program, and in turn the database.
    the classpath environment variable sounds like a good idea...will check into that. eventually we plan to wrap our software up in installshield so that would really be nice. clients could be ignorant of environment variables and still be able to run everything.
    my solution for now has been to find my jar file by recursively searching the c drive. and use GetFilePath() to get the full path and pass that to JNI_CreateJavaVM. i did get it to work...just wondering if this is a good idea.
    i was thinking that if the dll is in the same folder as the jar file i could just use dot notation but that just doesnt seem like a good idea to make that assumption. but i think java does something similar 'cause Sun says not to move the java.dll file.
    thanks for your input,
    txjump

  • Classpath from Web Start

    Hello!
    I need make following funcionality : from GUI application, opne new JFrame in another JVM.
    I do it like ->
                    String mainClass = MainClass.class.getName();
                    String classPath = System.getProperty("java.class.path");
    System.out.println(" classpath -> " + classPath ); // when run it from Web Start in output see :   claspath -> C:\Program Files\Java\jre6\lib\deploy.jar
                    ProcessBuilder pb = new ProcessBuilder( "java", "-classpath", classPath, mainClass );
                    try {
                        taProcess = pb.start();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }When I run it from my IDE - everything working fine. I can run something in other JVM.
    But if I run it from Java Web Start, I get wrong classPath (web starts classPath)
    Question is : How can I get my application class path, when I run it from Web start?? ( press on jnlp link)

    You code make use of manifest of the jar file to reload the classpath.
    THanks,
    Jyno

Maybe you are looking for

  • Sale Order & Production Order

    Hi! Friends is there any table that links Sale Order and Production Order.  In a report i need to display the Production order based on the sale order . as there is no key field for the table MSEG im not able to use it. i have tried using the table A

  • A question from a new Blackberry user

    Hi all, I will be going for the 9360, but unfortunatly, my operator doesn't seem to support the Blackberry phones. There are a few others that do that here, but then you need to subscribe to the Blackberry service. Does anyone know if I will be able

  • Sometimes notes sustain when they shouldn't. How can I fix this?

    When inputting notes either with my midi keyboard or directly with the pencil tool, sometimes the notes sustain even though the note is played or input as a short note. First it happened with the steel guitar exs internal synth sound input with penci

  • Lightroom 2.2 says my PC is out of memory?!?

    Sometimes LR will display this message: " Your disk "Lokal disk (C:), which contains your Lightroom catalog, is critically low on space. Lightroom has saved the contents of your catalog. You must now remove files or empty the trash to make at least 2

  • Company namespace

    Hi all, I'm new to SAP and am currently taking the elearning for the SDK.  One of the lessons indicated it was necessary for a company to obtain a company namespace.  My question is do we only need one namespace for our company or would we need a dif