3 Replies Latest reply on Jul 9, 2004 7:22 PM by songhai

    problem finding classes in /classes dir of WAR

    maniarkm

      Hi,

      I have a class that I want to access in jsp page. It does not belong to any package so I have placed it in at the root of the classes directory.

      When I try to import it I get the following error:

      [javac] D:\jboss-3.2.3\server\default\work\MainEngine\localhost\producer\xsys\home\index_jsp.java:12: '.' expected
      [javac] import sys_HTTP_Defines;

      It looks as if you cannot import a class that belongs to no package.

      I took out the import statement as the class should be on the classpath, so I have also tried to use it without importing it and I get a cannot resolve symbol error, basically telling me that it cannot be found.

      What is the correct way to access classes on the root of the /classes dir in a WAR?

      Any thoughts anyone?

      Cheers,

      Mark

        • 1. Re: problem finding classes in /classes dir of WAR
          songhai


          I am having the identical problem. I'm new to this however so the
          solution may be trivial. But could someone please point me in the right direction.

          • 2. Re: problem finding classes in /classes dir of WAR

            Hi folks,

            it definitely does not work to put a single class in the import statement as in "import MyClass;". This is prohibited by the javac itself.

            Besides that it's never a good idea to use classes with no package. Always use at least a single package - what's so difficult about it? It's just an additional folder and you get all the stuff of importing, correct class loader visiblity and so on.

            Unfortunately I was not able to dig deeper into it until now. Maybe there's even a rule for classes in a web application not to be put into the default package... I just know that's not a good idea.

            Hope that helped,

            René

            • 3. Re: problem finding classes in /classes dir of WAR
              songhai

              yes it did.
              I eventually figured as much and went the 'package' route.
              Thanks