Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > java packages

Reply
Thread Tools

java packages

 
 
frank
Guest
Posts: n/a
 
      06-20-2005


trying to make a java application to use packages now and having lots of
problems and i don't know why.

Just added to the top of each source file

package DBS_Intercept;

Compiled and and got the followig errors from Jbuilder

"DBS.java": Package
C:\data\JBFSA\may_05_demo_code\DBS_Intercept\DBS.j ava stated in source
DBS_Intercept does not match directory
C:\data\JBFSA\may_05_demo_code\DBS_Intercept\DBS.j ava. at line 37, column 9
"XSS.java": Package
C:\data\JBFSA\may_05_demo_code\DBS_Intercept\XSS.j ava stated in source
DBS_Intercept does not match directory
C:\data\JBFSA\may_05_demo_code\DBS_Intercept\XSS.j ava. at line 14, column 9
"JBFSAUtility.java": Package
C:\data\JBFSA\may_05_demo_code\DBS_Intercept\JBFSA Utility.java stated in
source DBS_Intercept does not match directory
C:\data\JBFSA\may_05_demo_code\DBS_Intercept\JBFSA Utility.java. at line
13, column 9
"XSSDP.java": Package
C:\data\JBFSA\may_05_demo_code\DBS_Intercept\XSSDP .java stated in source
DBS_Intercept does not match directory
C:\data\JBFSA\may_05_demo_code\DBS_Intercept\XSSDP .java. at line 15,
column 9
"RunDBS.java": Package
C:\data\JBFSA\may_05_demo_code\DBS_Intercept\RunDB S.java stated in
source DBS_Intercept does not match directory
C:\data\JBFSA\may_05_demo_code\DBS_Intercept\RunDB S.java. at line 10,
column 9
"CSDSMsg.java": Package
C:\data\JBFSA\may_05_demo_code\DBS_Intercept\CSDSM sg.java stated in
source DBS_Intercept does not match directory
C:\data\JBFSA\may_05_demo_code\DBS_Intercept\CSDSM sg.java. at line 16,
column 9


It's complaining about the package line in each case. Now if I use a
normal javac compile for each class it complains about not finding the
classes in each of the files (now because of the package statement).
Don't use packages it works fine. Never have a lot of luck with
packages I must be missing something fundamental here. The source and
class files are to all be in same directory DBS_Intercept

Any thoughts?

Thanks,

Frank


 
Reply With Quote
 
 
 
 
Andrew Thompson
Guest
Posts: n/a
 
      06-20-2005
On Mon, 20 Jun 2005 11:02:31 -0400, frank wrote:

> trying to make a java application to use packages now and having lots of
> problems and i don't know why.
>
> Just added to the top of each source file
>
> package DBS_Intercept;


Common Java package name nomenclature is to use all
lower case for package names, and no '_' characters.

[ Class names generally have EachWordStartUpperCase -
while methods and attributes are - firstWordLowerCase. ]

(snip JBuilder stuff)
...
> It's complaining about the package line in each case. Now if I use a
> normal javac compile ..


I suggest it is important to get that right first,
so let's have a look..

>..for each class it complains about not finding the
> classes in each of the files (now because of the package statement).
> Don't use packages it works fine.


[ Unfortunately, you cannot get very far without using packages. ]

>..Never have a lot of luck with
> packages I must be missing something fundamental here. The source and
> class files are to all be in same directory DBS_Intercept


... what is the *exact* command you are uing to compile the
..java source files and from which directory?

For example, often the developer compiles from 'the top'.
So if there is a package org.utils with source FileUtils.java
the source might be put in folder..

C:\Projects\Java\BasicTools\org\utils\

...which might be compiled from..

C:\Projects\Java\BasicTools\

...then Java source file FileTool.java (in package 'utils')
might be compiled by calling ..

C:\Projects\Java\BasicTools\>javac org/utils/FileTool.java

A class file with the correct package information should
now be inside C:\Projects\Java\BasicTools\org\utils\.

In closing, I will suggest that there is a better group
for sorting such problems..
<http://www.physci.org/codes/javafaq.jsp#cljh>

HTH

--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane
 
Reply With Quote
 
 
 
 
frank
Guest
Posts: n/a
 
      06-20-2005
Using the following to compile manually. Not quite sure how to see how
Jbuilder is building it. All source in local directory

set
PROD_CLASSPATH=%CLASSPATH%;.;;C:\data\JBFSA\may_05 _demo_code\lib;C:\tomcat-j
wsdp-1.4\jaxrpc\lib\jaxrpc-api.jar;%AXIS_LIB%\axis.jar;%AXIS_LIB%\commons-discov
ery-0.2.jar;%AXIS_LIB%\commons-logging-1.0.4.jar;%AXIS_LIB%\jaxrpc.jar;%AXIS_LIB
%\log4j-1.2.8.jar;%AXIS_LIB%\saaj.jar;%AXIS_LIB%\wsdl4-1.5.1.jar;C:\xerces-2_6_2
\xercerImpl.jar;C:\data\JBFSA\may_05_demo_code\lib \soap.jar;C:\data\JBFSA\may_05
_demo_code\lib\xssrpc.jar;C:\xalan-j_2_6_0\bin\xalan.jar


javac -classpath %PROD_CLASSPATH% JBFSAUtility.java
javac -classpath %PROD_CLASSPATH% CSDSMsg.java
javac -classpath %PROD_CLASSPATH% DBS.java
javac -classpath %PROD_CLASSPATH% RunDBS.java
javac -classpath %PROD_CLASSPATH% XSS.java
javac -classpath %PROD_CLASSPATH% XSSDP.java

Andrew Thompson wrote:
> On Mon, 20 Jun 2005 11:02:31 -0400, frank wrote:
>
>
>>trying to make a java application to use packages now and having lots of
>>problems and i don't know why.
>>
>>Just added to the top of each source file
>>
>>package DBS_Intercept;

>
>
> Common Java package name nomenclature is to use all
> lower case for package names, and no '_' characters.
>
> [ Class names generally have EachWordStartUpperCase -
> while methods and attributes are - firstWordLowerCase. ]
>
> (snip JBuilder stuff)
> ..
>
>>It's complaining about the package line in each case. Now if I use a
>>normal javac compile ..

>
>
> I suggest it is important to get that right first,
> so let's have a look..
>
>
>>..for each class it complains about not finding the
>>classes in each of the files (now because of the package statement).
>>Don't use packages it works fine.

>
>
> [ Unfortunately, you cannot get very far without using packages. ]
>
>
>>..Never have a lot of luck with
>>packages I must be missing something fundamental here. The source and
>>class files are to all be in same directory DBS_Intercept

>
>
> .. what is the *exact* command you are uing to compile the
> .java source files and from which directory?
>
> For example, often the developer compiles from 'the top'.
> So if there is a package org.utils with source FileUtils.java
> the source might be put in folder..
>
> C:\Projects\Java\BasicTools\org\utils\
>
> ..which might be compiled from..
>
> C:\Projects\Java\BasicTools\
>
> ..then Java source file FileTool.java (in package 'utils')
> might be compiled by calling ..
>
> C:\Projects\Java\BasicTools\>javac org/utils/FileTool.java
>
> A class file with the correct package information should
> now be inside C:\Projects\Java\BasicTools\org\utils\.
>
> In closing, I will suggest that there is a better group
> for sorting such problems..
> <http://www.physci.org/codes/javafaq.jsp#cljh>
>
> HTH
>


 
Reply With Quote
 
Andrew Thompson
Guest
Posts: n/a
 
      06-20-2005
On Mon, 20 Jun 2005 15:34:41 -0400, frank wrote:
> Andrew Thompson wrote:
>> On Mon, 20 Jun 2005 11:02:31 -0400, frank wrote:


(Please refrain from top-posting - I find it most confusing)
See further comments below, 'in-line with trim'.
<http://www.physci.org/codes/javafaq.jsp#netiquette>

>>>trying to make a java application to use packages now and having lots of
>>>problems and i don't know why.
>>>
>>>Just added to the top of each source file
>>>
>>>package DBS_Intercept;


>>>It's complaining about the package line in each case. Now if I use a
>>>normal javac compile ..


>> .. what is the *exact* command you are uing to compile the
>> .java source files ..


> set
> PROD_CLASSPATH=%CLASSPATH%;.;....
>
> javac -classpath %PROD_CLASSPATH% JBFSAUtility.java

.....
> javac -classpath %PROD_CLASSPATH% XSSDP.java


>> ...and from which directory?


...it seems from the commands above that you are doing
this from inside the 'DBS_Intercept' directory itself -
can you confirm that?

--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane
 
Reply With Quote
 
frank
Guest
Posts: n/a
 
      06-21-2005
Yes I am doing it in that directory. Do I need to do it above that
directory?
>
> ..it seems from the commands above that you are doing
> this from inside the 'DBS_Intercept' directory itself -
> can you confirm that?
>


 
Reply With Quote
 
Andrew Thompson
Guest
Posts: n/a
 
      06-21-2005
On Mon, 20 Jun 2005 21:14:25 -0400, frank wrote:

> Yes I am doing it in that directory. Do I need to do it above that
> directory?
>>
>> ..it seems from the commands above that you are doing
>> this from inside the 'DBS_Intercept' directory itself -
>> can you confirm that?


It can be done from within the directory or above it, but I suspect
it makes sense to get *one* approach working, so I am trying to bring
you around to using the one I know best. Working out the variatian
that allows it to work from within the the package directory is more
of a DOS/Command Line thing.

In any case, if you go back to my original post, you will notice that
when compiling this package/JavaClass.java, I did it from the parent
directory but called the java files by their package/class names
(package/JavaClass.java).

This (is one way of) making sure the package statements are correctly
written in the resulting class files.

--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane
 
Reply With Quote
 
Raymond DeCampo
Guest
Posts: n/a
 
      06-21-2005
Andrew Thompson wrote:
> On Mon, 20 Jun 2005 21:14:25 -0400, frank wrote:
>
>
>>Yes I am doing it in that directory. Do I need to do it above that
>>directory?
>>
>>>..it seems from the commands above that you are doing
>>>this from inside the 'DBS_Intercept' directory itself -
>>>can you confirm that?

>
>
> It can be done from within the directory or above it, but I suspect
> it makes sense to get *one* approach working, so I am trying to bring
> you around to using the one I know best. Working out the variatian
> that allows it to work from within the the package directory is more
> of a DOS/Command Line thing.
>
> In any case, if you go back to my original post, you will notice that
> when compiling this package/JavaClass.java, I did it from the parent
> directory but called the java files by their package/class names
> (package/JavaClass.java).
>
> This (is one way of) making sure the package statements are correctly
> written in the resulting class files.
>


I think perhaps you meant something else by the above statement. The
package statements in the resulting class files are a function of the
package statements in the java source files and do not depend on the
directory structure.

I think you probably meant that the resulting class files and their
directory structure correspond to the package statements, making the
class files "usable".

Something that might help the OP here is to use the -d switch to javac,
which causes the compiler to place the class files in a separate
directory from the source files. I personally prefer to have the
compiled classes separate from the source code and I think it would be
an educational exercise in any case.

If this cause additional confusion, it may be something the OP wants to
try after getting things working.

HTH,
Ray

--
XML is the programmer's duct tape.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Python Packages : A loomingproblem? packages might no longer work? (well not on your platform or python version anyway) David Lyon Python 19 04-23-2009 11:10 PM
Advice on converting hashed packages to pseudo-hashed packages Ian Perl Misc 3 02-12-2005 12:17 AM
Do the javax.imageio packages replace packages in com.sun.image? Paul Smith Java 0 11-18-2003 02:58 PM
Java Math packages Silvere Martin-Michiellot Java 3 10-06-2003 10:09 PM



Advertisments