AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

GIJ and paths and packages and the current directory

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Help
View previous topic :: View next topic  
Author Message
Guest






PostPosted: Thu May 17, 2007 1:55 am    Post subject: GIJ and paths and packages and the current directory Reply with quote



Suppose my current directory is /A/B/C/Home, starting from the root of
the Linux filesystem.

Under Home, I have a subdirectory 'camera" that contains all my java
classes. When Home is my current directory, I can execute my java
application by typing:

gij camera.MyEntryPoint

This works fine. Gij finds the MyEntryPoint class, executes the main
method, and all the other classes in my application are found with no
problem as they are needed by the application.

Now, if I want to execute the same sort of command, but do it when the
Linux root directory is my current directory, I thought I should be
able to do the following:

gij --cp /A/B/C/Home camera.MyEntryPoint

Unfortunately, this starts the first class, but the first line in the
MyEntryPoint.class that refers to another class (which are all in the
same camera directory) throws a NullPointerException and says unknown
source. I believe this means that the gij program can't seem to find
the other classes in the camera directory, but I don't know why.

All my classes are in the camera directory and I have a 'package
camera' declaration at the top of every source file.

What am I doing wrong?

gdhurst
Back to top
Eric Sosman
Guest





PostPosted: Thu May 17, 2007 2:09 am    Post subject: Re: GIJ and paths and packages and the current directory Reply with quote



jmail (AT) hursttechnical (DOT) com wrote:
Quote:
Suppose my current directory is /A/B/C/Home, starting from the root of
the Linux filesystem.

Under Home, I have a subdirectory 'camera" that contains all my java
classes. When Home is my current directory, I can execute my java
application by typing:

gij camera.MyEntryPoint

This works fine. Gij finds the MyEntryPoint class, executes the main
method, and all the other classes in my application are found with no
problem as they are needed by the application.

Now, if I want to execute the same sort of command, but do it when the
Linux root directory is my current directory, I thought I should be
able to do the following:

gij --cp /A/B/C/Home camera.MyEntryPoint

Unfortunately, this starts the first class, but the first line in the
MyEntryPoint.class that refers to another class (which are all in the
same camera directory) throws a NullPointerException and says unknown
source. I believe this means that the gij program can't seem to find
the other classes in the camera directory, but I don't know why.

That's an unlikely reason for NullPointerException,
which means that you have tried to refer to an object via
a reference whose value is null. Classes that can't be
found when needed produce ClassNotFoundException (maybe
some others in unusual circumstances; I'm not sure), but
not NPE.

You *could* get NPE in a roundabout way, e.g., with

Class c = null;
try {
c = Class.forName("MissingClass");
} catch (ClassNotFoundException ex) {
// ignore (bad idea!)
}
Field f = c.getDeclaredField("name"); // possible NPE

.... but unless you're indulging in this sort of foolishness
I don't see how a missing class could produce an NPE. You
probably need to seek other causes; "missing class" is most
likely a red herring.

--
Eric Sosman
esosman@acm-dot-org.invalid
Back to top
Roedy Green
Guest





PostPosted: Thu May 17, 2007 7:11 am    Post subject: Re: GIJ and paths and packages and the current directory Reply with quote



On 16 May 2007 13:55:33 -0700, jmail (AT) hursttechnical (DOT) com wrote, quoted
or indirectly quoted someone who said :

Quote:
What am I doing wrong?

see http://mindprod.com/jgloss/classpath.html

when you have a classpath, you can execute from any directory.

Sorry, I don't know how to set up a permanent classpath in Linux.

I can tell you the element are separated by : instead of ;. If you
figure it out, please tell me so I can add it to the entry.

I vaguely recall doing this a decade ago, where I did some sort of
export in a bash script.
--

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.