473,511 Members | 16,983 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

null pointer exceptions

It seems to be the case that there are some null pointer exceptions which
Java can handle, but Jython can't. Which doesn't make sense to me, as with
Jython, it is Java which is doing the work.

Are there any good guides to this?

I have a class which includes adding an ImageIcon. If the required graphic
resource isn't present, there is a NullPointerException. Java doesn't care
- the straight Java program handles it internally and gets on with life.
But when I include it from Python, it explodes.

It may be because the resource is specified using a relative pathname.
When Jython executes, it may be not using the current directory as its'
base for relative paths, but could be using JYTHON_HOME, which could lead
to this behaviour.

Can anyone tell me what Jython uses for its' relative path base?
Can anyone describe how Jython handles exceptions that is different from
Java?

Thanks,
-Tennessee
Jul 18 '05 #1
1 9578
Tennessee James Leeuwenburg wrote:
I have a class which includes adding an ImageIcon. If the required
graphic
resource isn't present, there is a NullPointerException. Java doesn't
care
- the straight Java program handles it internally and gets on with
life.
But when I include it from Python, it explodes.


A java.lang.NullPointerException is just an exception like anything
else. Can't you just catch it?

max@oxygen:~/tmp% cat NullCaster.java
import java.lang.*;

public class NullCaster
{
public static void main(String[] args)
{
Object nullObject = null;
String nullString = (String) nullObject;
nullString.length();
}
}
max@oxygen:~/tmp% javac NullCaster.java
max@oxygen:~/tmp% jython
Jython 2.1 on java1.4.1 (JIT: null)
Type "copyright", "credits" or "license" for more information.
import java.lang
import NullCaster
try:

.... NullCaster.main([])
.... except java.lang.NullPointerException, e:
.... print 'oops:', e
....
oops: java.lang.NullPointerException

--
Erik Max Francis && ma*@alcyone.com && http://www.alcyone.com/max/
__ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/ \ Wretches hang that jurymen may dine.
\__/ Alexander Pope
Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

26
7684
by: HP | last post by:
Hi guys i wana remove this warning which i am getting during my codcomilation. the warning is - Possible use of null pointer 'PnoSytGenericTest::_response' in left argument to operator '->'
69
5493
by: fieldfallow | last post by:
Hello all, Before stating my question, I should mention that I'm fairly new to C. Now, I attempted a small demo that prints out the values of C's numeric types, both uninitialised and after...
18
2950
by: Denis Petronenko | last post by:
Hello, in the following code i have segmentaion fault instead of exception. Why? What i must to do to catch exceptions in such situation? Used compiler: gcc version 3.3.6 (Debian 1:3.3.6-13) ...
3
2159
by: Michael | last post by:
Hi, Could you tell me how to under the following statements? Does it mean each and every memory allocation will check all the pointer no matter a null pointer or not? Right? Thanks in advance! ...
31
17666
by: leonm54 | last post by:
I remember that this is a bad practice, but can not find a definitive resource that states it is bad and why. Can anyone help?
3
2074
by: Alexander Behnke | last post by:
Hello, I am currently facing a problem with a calloc function call which returns a NULL pointer while in a debugging environment. If I start the same executable from the shell (not via the...
76
4574
by: valentin tihomirov | last post by:
As explained in "Using pointers vs. references" http://groups.google.ee/group/borland.public.delphi.objectpascal/browse_thread/thread/683c30f161fc1e9c/ab294c7b02e8faca#ab294c7b02e8faca , the...
28
1829
by: rahul | last post by:
#include <stdio.h> int main (void) { char *p = NULL; printf ("%c\n", *p); return 0; } This snippet prints 0(compiled with DJGPP on Win XP). Visual C++ 6.0
18
3236
by: sanjay | last post by:
Hi, I have a doubt about passing values to a function accepting string. ====================================== #include <iostream> using namespace std; int main() {
0
7144
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7427
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7085
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5069
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4741
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3214
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1577
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
449
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.