Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Bug? Java 1.1 in X11R5 environment

0 views
Skip to first unread message

Becky King

unread,
Jun 12, 1997, 3:00:00 AM6/12/97
to

This is a multi-part message in MIME format.

--------------2781E494446B9B3D794BDF32
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

--
be...@lanl.gov
Rebecca L. King
Los Alamos National Laboratory
NIS-3
505 665-6603

--------------2781E494446B9B3D794BDF32
Content-Type: text/plain; charset=us-ascii; name="post.msg"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="post.msg"


I am having a problem with converting a Java 1.02 application to
a Java 1.1 program.

I work in an X11 R5 server environment.

The Java 1.02 version runs in that environment.

The Java 1.1 version does not.

HERE IS THE CURIOUS PART.

In my attempt to figure out why the 1.1 version was not
working, I tried running the 1.1 version in the OpenLook server
environment. Voila! the 1.1 version works in that environment.

The messages I get when the 1.1 version in the X11R5 environment
are as follows:

java.lang.NullPointerException
at sun.awt.motif.MFramePeer.<init>(MFramePeer.java:59)
at sun.awt.motif.MToolkit.createFrame(MToolkit.java:153)
at java.awt.Frame.addNotify(Frame.java)
at MainFrame.<init>(MainFrame.java:14)
at MainFrame.main(MainFrame.java:48)

I read in the faqs the messages on addNotify and have taken
that into account in my code. I realize that show() calls
addNotify, so in the example code it does not matter if my
addNotify() is commented out, the result is the same.


I have included the source that I am using to test this
problem. All it does it pop up a Frame. There is no
event handling added to this example. One has to do
a control c to exit the program.

I am getting kind of desperate trying to figure this out as
I have a tight deliverable date on this project and really
need the answer to this dilema ASAP. I need the code to run
in both environments.

The output from the testing session follows:


starfire% source ~bk/.cshrc.java.1.02

starfire% echo $CLASSPATH
./:/opt2/Solaris/local/java/JDK/lib/classes.zip

starfire% javac MainFrame.java


starfire% java MainFrame The main Frame is displayed on
my workstation now. I control
c to exit.


starfire% source ~bk/.cshrc.java.1.1

starfire% echo $CLASSPATH
./:/opt2/Solaris/local/java/jdk1.1/lib/classes.zip

starfire% javac MainFrame.java

Note: MainFrame.java uses a deprecated API. Recompile with "-deprecation" for details.
1 warning

starfire% java MainFrame
java.lang.NullPointerException
at sun.awt.motif.MFramePeer.<init>(MFramePeer.java:59)
at sun.awt.motif.MToolkit.createFrame(MToolkit.java:153)
at java.awt.Frame.addNotify(Frame.java)
at MainFrame.<init>(MainFrame.java:18)
at MainFrame.main(MainFrame.java:43)
^Cstarfire%

The source follows:


import java.awt.*;

public class MainFrame extends Frame {

public MainFrame() {

setLayout(null);
addNotify();
resize(insets().left + insets().right + 338,insets().top + insets().bottom + 211);
setTitle("Java 1.1 Test");

mainMenuBar = new java.awt.MenuBar();

nothingMenu = new java.awt.Menu("This Does Nothing");
nothingMenu.add("Null");
mainMenuBar.add(nothingMenu);

setMenuBar(mainMenuBar);
}

public MainFrame(String title) {
this();
setTitle(title);
}

public synchronized void show() {
move(50, 50);
super.show();
}


static public void main(String args[]) {
(new MainFrame()).show();
}


java.awt.MenuBar mainMenuBar;
java.awt.Menu nothingMenu;
}

--------------2781E494446B9B3D794BDF32--


Robert Lynch

unread,
Jun 12, 1997, 3:00:00 AM6/12/97
to Becky King

This is the so-called "font problem"; see Peter van der Linden's FAQ at:

http://www.best.com/~pvdl/javafaq.txt

For your convenience I give the Q&A here:
--------
...
4.2 Why do I get this when using JDK 1.1 under X Windows?


java.lang.NullPointerException
at sun.awt.motif.MFramePeer.<init>(MFramePeer.java:59)
at sun.awt.motif.MToolkit.createFrame(MToolkit.java:153)
at java.awt.Frame.addNotify(Frame.java)

at java.awt.Window.pack(Window.java)

A. There's a missing font on your system. Move font.properties from
the "lib" subdirectory aside to font.properties.bak Then it won't
look for the font and fail to find it.

The problem occurs because the Motif AWT libraries use
the Font "plain Dialog 12 point" as a fall-back default font.
Unfortunately, when using a remote X server sometimes this font
isn't
available.
...
-----
I wish I could figure out so easily why the "Java in a Nutshell, 2nd
Ed." Ch. 8 ScribbleFrame example on Linux emits:
-----
[user@ravel ch08]$ java ScribbleFrame
java.lang.NullPointerException
at sun.awt.motif.MMenuPeer.<init>(MMenuPeer.java:44)
at sun.awt.motif.MToolkit.createMenu(MToolkit.java:162)
at java.awt.Menu.addNotify(Menu.java:93)
at java.awt.PopupMenu.addNotify(PopupMenu.java:74)
at java.awt.Component.addNotify(Component.java:2085)
at java.awt.Container.addNotify(Container.java:1001)
at java.awt.ScrollPane.addNotify(ScrollPane.java:396)
at java.awt.Container.addNotify(Container.java:1001)
at java.awt.Window.addNotify(Window.java:103)
at java.awt.Frame.addNotify(Frame.java:145)
at java.awt.Window.pack(Window.java:115)
at ScribbleFrame.<init>(ScribbleFrame.java:69)
at ScribbleFrame.main(ScribbleFrame.java:23)
-----
but works on... gr! Win95.

Bob L.
--
Robert Lynch-Berkeley CA USA-r...@best.com
http://www.best.com/~rmlynch/
--


Becky King wrote:
>
> --
> be...@lanl.gov
> Rebecca L. King
> Los Alamos National Laboratory
> NIS-3
> 505 665-6603
>

> ---------------------------------------------------------------

Otmar Schwan

unread,
Jun 12, 1997, 3:00:00 AM6/12/97
to


Hi Rebecca,

i can´t following your Enviroment-Problem - i don´t have a Unix-Machine.

But check this:

java.awt.MenuBar mainMenuBar;
java.awt.Menu nothingMenu;

why - ok that´s your taste- place you the Reference on the End of the
Class ??

perhaps the Compiler don´t reach these lines befor you
instantiated your Menu-Objects ?

or - you have no LayoutManger (null) - perhabs a Problem with X-Windows
?


or - why do you take not a Reference for your Mainframe in your
main-Method?
e.g.: MainFrame MF = new MainFrame()
MF.show();

or - why do not call the Superclass Frame-Constructor in your derived
Class?
like:
public MainFrame()
{
super();

if you specified a Constructor with Arguments the
Default-Constructor
of your class is not called !
Ok - you define a Default-Constructor , but i think you
must - call then the Default-Constructor of the Superclass Frame !


ok - thats my Ideas

Hope this will helps

Sorry for my English!


regards,

Otmar

--
****Otmar Schwan TyBrain Consulting Heidenheim/Germany ***
*** Web: www.t-online.de/home/otmar.schwan **********
*** EMail: otmar....@t-online.de **********
************************************************************

Dan Warburton

unread,
Jul 2, 1997, 3:00:00 AM7/2/97
to Otmar....@t-online.de

Well I too wrote an application that has similar problems, I cannot run
a java application
on a sun CDE environemt and remote the display to another system (Linux,
or SGI). Are
you remoting the x-display? Linux to SGI works like a charm, SGI to
linux works.


Robert Lynch

unread,
Jul 2, 1997, 3:00:00 AM7/2/97
to Dan Warburton

[newsgroup list trimmed]

This problem was, I believe, the "font" problem, described in Peter van
der Linden's Java Programmer's FAQ, at:

http://www.best.com/~pvdl/javafaq.txt

See question 4.2:
---------------


4.2 Why do I get this when using JDK 1.1 under X Windows?

java.lang.NullPointerException
at sun.awt.motif.MFramePeer.<init>(MFramePeer.java:59)
at sun.awt.motif.MToolkit.createFrame(MToolkit.java:153)
at java.awt.Frame.addNotify(Frame.java)

at java.awt.Window.pack(Window.java)

A. There's a missing font on your system. Move font.properties from
the "lib" subdirectory aside to font.properties.bak Then it won't
look for the font and fail to find it.

The problem occurs because the Motif AWT libraries use
the Font "plain Dialog 12 point" as a fall-back default font.
Unfortunately, when using a remote X server sometimes this font
isn't
available.

----------
Hope this helps.

Bob L.
--
Robert Lynch-Berkeley CA USA-r...@best.com
http://www.best.com/~rmlynch/
--

0 new messages