Optimal Directory Structure?
I realize that there is not one answer to this question but I would like some of you veteran java/linux developers to suggest what the optimal directory structure and setup of the CLASSPATH variable is. I am, frankly, a C++ programmer trying to learn java and I am continually frustrated over the myriad ways I can be foobared by CLASSPATH. And then packages on top of that. I have been trying the different java tools that are out there, such as Jacob and JDE. Every time I do, I seem to spend an inordinate amount of time chasing down problems that are due to different ideas from the developers of these packages of how and where CLASSPATH should be defined. In the environment? In the makefile? In the "project file"? How to set it so that the setup that works for compilation also works for running, debugging, etc. I know it isn't rocket science, but it is annoying. What I am looking for is a strategy. I want to be able to set it one way and forget about it, at least until the next project. Any advice would be appreciated.
Re: More keyboard problems
Joachim Schaaf wrote:
> Steve Cohen wrote:
> >
> > I am getting my feet wet with java-linux.
> > As a first step, I am simply copying code from the disk included with
> > the book
> > "Java for C/C++ Programmers" by Michael C. DaConta.
> > The first "Hello World" program worked okay but the second one,
> > attached, does not.
> > On my RedHat 5.0 systems (yes, I've upgraded glibc and ld) the dialog
> > comes up but no keyboard input shows up. Any idea why?
>
> > // our book class
> > import book;
>
> I guess without this package (book) noone can compile it ...
>
> Joachim
> --
> Joachim Schaaf
> IoS - Gesellschaft fuer innovative Softwareentwicklung mbH
> Donatusstrasse 127-129, 50259 Pulheim, Tel/Fax: ++49-2234-986432/3
> Email: [EMAIL PROTECTED], WWW: http://www.ios-online.de/
Sorry about that. Okay, it's all there now. src1-7.java is a new version
incorporating Juergen Kreileder's code fix. It still doesn't work.
src1-4.java has the book class.
// gui classes
import java.awt.Frame;
import java.awt.TextField;
import java.awt.Panel;
import java.awt.Button;
import java.awt.GridLayout;
import java.awt.Event;
import java.awt.Color;
import java.awt.Label;
// our book class
import book;
// a utility class
import java.util.Vector;
class bookWindow extends Frame {
TextField title;
TextField author;
TextField publisher;
Vector theBooks;
int currentIdx;
bookWindow() {
super("Book Shelf");
// initialize the growable array
theBooks = new Vector(3);
currentIdx = 0;
Panel centerPanel = new Panel();
centerPanel.setLayout(new GridLayout(0, 2));
centerPanel.add(new Label(" Title"));
centerPanel.add(title = new TextField(20));
centerPanel.add(new Label(" Author"));
centerPanel.add(author = new TextField(20));
centerPanel.add(new Label(" Publisher"));
centerPanel.add(publisher = new TextField(20));
add("Center", centerPanel);
Panel bottomPanel = new Panel();
bottomPanel.add(new Button("store"));
bottomPanel.add(new Button("clear"));
bottomPanel.add(new Button("prev"));
bottomPanel.add(new Button("next"));
bottomPanel.add(new Button("exit"));
add("South", bottomPanel);
move(200, 100);
pack();
show();
}
public boolean handleEvent(Event evt) {
if (evt.id == Event.ACTION_EVENT)
{
if ("store".equals(evt.arg))
{
book aBook = new book(title.getText(),
author.getText(),
publisher.getText());
theBooks.addElement(aBook);
currentIdx = theBooks.size();
return true;
}
if ("clear".equals(evt.arg))
{
title.setText("");
author.setText("");
publisher.setText("");
return true;
}
if ("prev".equals(evt.arg))
{
if (currentIdx > 0)
{
book aBook = (book) theBooks.elementAt(--currentIdx);
title.setText(aBook.getTitle());
author.setText(aBook.getAuthor());
publisher.setText(aBook.getPublisher());
}
return true;
}
if ("next".equals(evt.arg))
{
if (currentIdx < (theBooks.size()-1))
{
book aBook = (book) theBooks.elementAt(++currentIdx);
title.setText(aBook.getTitle());
author.setText(aBook.getAuthor());
publisher.setText(aBook.getPublisher());
}
return true;
}
if ("exit".equals(evt.arg))
{
System.exit(0);
}
}
return super.handleEvent(evt);
}
}
class bookGUI {
public static void main(String args[])
{
new bookWindow();
}
}
// books.java
import java.lang.String;
import java.io.DataInputStream;
import java.lang.System;
import java.io.IOException;
class book {
protected String title;
protected String author;
protected String publisher;
book next;
book()
{
title = author = publisher = " ";
next = null;
}
book(book other)
{
title =
Re: More keyboard problems
Juergen Kreileder wrote: > Steve Cohen <[EMAIL PROTECTED]> writes: > > > Joachim Schaaf wrote: > > > > > Steve Cohen wrote: > > > > > > > > I am getting my feet wet with java-linux. > > > > As a first step, I am simply copying code from the disk included with > > > > the book > > > > "Java for C/C++ Programmers" by Michael C. DaConta. > > > > The first "Hello World" program worked okay but the second one, > > > > attached, does not. > > > > On my RedHat 5.0 systems (yes, I've upgraded glibc and ld) the dialog > > > > comes up but no keyboard input shows up. Any idea why? > > > > > > > // our book class > > > > import book; > > > > > > I guess without this package (book) noone can compile it ... > > You can compile the relevant stuff if you comment out the book stmts. > > > Sorry about that. Okay, it's all there now. src1-7.java is a new version > > incorporating Juergen Kreileder's code fix. It still doesn't work. > > src1-4.java has the book class. > > Your code works fine with JDK 1.1.6! > > Jürgen > Hmm, it works now for me too. Now to write some of my own code.
Re: Emacs and java...
I have been using SlickEdit (and its successor Visual Slick Edit) on DOS and Windows platforms for almost 10 years. I swear by them. You can configure it to just about any keystroke configuration you wish - vi, emacs, cua, your own hybrid. Plus you get a lot of bells and whistles in it besides the editor itself - code beautification, multifile search and replace with regular expressions, source control integration, a good differencer just to name a few. Five years ago, I would use this editor instead of the Visual C++ editor that was totally brain-dead. Now that VC's has been improved so as to be usable for many (but not all) tasks, I still find myself bringing up SlickEdit at least once or twice a day for one of the bells and whistles function. I've also used Codewright and prefer Slick, primarily for the ease in writing macros which get compiled right in the editor. In Codewright you had to write C code that compiled down into DLLs. The upshot was that I wrote useful macros, while the guys that were using Codewright never had time to do so. Never used any of these on unix platforms which I have far less experience with, but have occasionally wished for them. Peter Eddy wrote: > Liam Magee wrote: > > I don't know about either of the two editors mentioned, but I've been > using emacs and xemacs for quite a while and I don't see any reason to > switch, excepting of course, that emacs editors seem to be carpel-tunnel > inducing. > > peter > > > > > Hardly on topic but - based on the recommendation below, I've been > > evaluating slickedit and Codewright. Has anyone compared these two, and if > > this is not the place to discuss code editors, does anyone know of any > > mailing list which does? > > > > Liam Magee. > > > > > > > > Personally I avoid emacs when ever possible having used vi for years (ok, > > > decades). But - I recently came across a REAL programmers editor called > > > slickedit while looking for a Java code beautifier - see > > > www.slickedit.com > > > > > > This really made me sit up - it support emacs and vi (not to > > > mention that old > > > dos favourite brief) editing modes - including regular expressions. Good > > > support for Java/C/C++/et al, and includes a great code beautifier. Even > > > supported on Weird operating systems begining with W, but smile > > > :), it also > > > runs under X. > > > > > > "Linux - I can't believe it's not Microsoft" > > > Jerry T[EMAIL PROTECTED] > > >
Re: What's up with this?
My apoologies (and thanks) to all who responded to my poorly formulated original
question in this thread. I was in a hurry to leave town for the weekend and did a
much worse job than I had thought, of framing the issue.
In the first place, the code fragment should have shown both paint methods as
public as they were in my actual code. In the second place, I didn't define the
problem as precisely as I might have.
The key point in this fragment is this: both a.java and b.java import java.awt.*.
As some have pointed out, since both reside in the same directory, strictly
speaking it is not necessary to #import a from b. It in fact makes no difference
whether b imports a or not. The key point is that all of a's methods tHat I call
from b are accepted **EXCEPT** those methods which have parameters that are defined
in java.awt; these are **NOT** recognized and rejected by the compiler.
A more meaningful code fragment would have been this:
//file a.java
import java.awt.*;
public class a {
public void paint (Graphics g) {
...
}
public Point doSomethingWithAPoint (Point pt) { // fails to compile
pt.x += 7;
return pt;
}
public int doSomethingWithAnInt( int i ) {
return i + 2;
}
}
//file b.java:
import java.awt.*;
import a;
public class b {
public a A;
...
b() {
A = new a();
}
public void paint (Graphics g) { // fails to compile
A.paint(g);
}
public void doSomethingWithAPoint (Point pt) { // fails to compile
return A.doSomethingWithAPoint( pt );
}
public void doSomethingWithAnInt (int i) // compiler accepts.
return A.doSomethingWithAnInt(i);
}
}
The error message, by the way, is
"Method paint(java.awt.Graphics) not found in class a."
It almost seems as though the compiler thinks that the import of java.awt in a.java
has nothing to do with the import of the same class in b.java. That is the
problem I was trying to get around.
Now that I have more properly defined the problem, are there any solutions?
Re: Trouble JDK 1.1.6 + HOTJAVA
Alexandre Boissy wrote: > Steve Byrne wrote: > > > David Buddrige writes: > > > Hi all, > > > > > > I have recently downloaded JDK 1.1.6 from > > > ftp.progsoc.uts.edu.au/pub/Linux/java to run on my Redhat 5.1 system... > > > I've un-tar'ed it into /usr/local/jdk1.1.6, and then added the following > > > lines to my /etc/profile file > > > > > > PATH="$PATH:/usr/X11R6/bin:/usr/local/jdk1.1.6/bin" > > This is ok. > > > > > export JAVA_HOME="/usr/local/jdk1.1.6 > > Wrong. > > > export CLASSPATH="/usr/local/jdk1.1.6/lib/classes.zip" > > Nope. > > > > * You DO NOT need to set JAVA_HOME. Doing so can be bad for your health > > * You only need to set CLASSPATH when you want it to contain something > > other than '.' and the classes.zip (in your case, I think you didn't > > need that, but it depends your hellow world's package structure > > and what your current directory is). > > > > Try running again w/out the bad env var settings. Did you get the glibc > > version of the JDK? That's the one that you want for RH 5.1. > > > > Steve > > I have the same problem than David, but I have also Hotjava on my system. And > Hotjava needs JAVA_HOME ! What can I do ? > > Thanks, Alex. Let me chime in here too. I have built, under linux, a toy application and also an applet. It uses swing. All the files are in one package (including the app main file and the applet file). I have jar'ed the class files all up into one jar file. Under linux, I can get both the app and the applet (under appletviewer) to run. When I carry the jar file over to a Windows95 system, it will not run. I get NoClassDefFoundErrors. Can someone show me an example of the RIGHT way to embed a jar file containing an applet and other classes in the same package on an html page that is truly portable? What, if any, classpath support is needed in the target environment? How is swing support to be provided on the target environment? I'm pulling my hair out, guys. Any help would be much appreciated.
Write Once Run Anywhere?
I have built an application and an applet using jdk 1.1.6 under linux RedHat 5.0. Both the application and the applet (which use much of the same code) compile and work under linux. When I copy the class files to a Win95 system, they fail with NoClassDefFoundError. If, instead, I copy the .java files to the Win95 system and compile them there, then again, both the applet and the application run exactly as they did under linux. Why could this be happening?
Re: Write Once Run Anywhere?
Sean Starkey wrote: > On Wed, 30 Sep 1998, Steve Cohen wrote: > > > I have built an application and an applet using jdk 1.1.6 under linux > > RedHat 5.0. Both the application and the applet (which use much of the > > same code) compile and work under linux. > > When I copy the class files to a Win95 system, they fail with > > NoClassDefFoundError. > > If, instead, I copy the .java files to the Win95 system and compile them > > there, then again, both the applet and the application run exactly as > > they did under linux. > > > > Why could this be happening? > > Did you check your CLASSPATH? I compile things on Linux all the time > and run them in Win95. I compile things on Digital Unix and run them > in Linux and Win95. I compile things on Win95 and run them in Linux > and Digital Unix. Get the idea? :) > > Sean > > === Friends don't let friends use DOS... === > Sean Starkey [EMAIL PROTECTED] WWW: http://rmi.net/~starkey ICQ: 4863014 > Check out Universe! - http://rmi.net/~starkey/Universe No, that's not it. The classpath is right. With the same classpath, under Win95, the copied CLASS files fail, but compiled source files work.
Re: Write Once Run Anywhere?
Ross Golder wrote: > Steve Cohen wrote: > > > > No, that's not it. The classpath is right. With the same classpath, under > > Win95, the copied CLASS files fail, but compiled source files work. > > You're not using a Microsoft Java VM (/compiler) ? > > I've never used them but from what I hear, they like to 'do their own > thing'. > > -- > Ross No. I am using javac on both sides.
Re: Write Once Run Anywhere?
Ming-Ching Tiew wrote: > Steve Cohen wrote: > > > > I have built an application and an applet using jdk 1.1.6 under linux > > RedHat 5.0. Both the application and the applet (which use much of the > > same code) compile and work under linux. > > When I copy the class files to a Win95 system, they fail with > > NoClassDefFoundError. > > If, instead, I copy the .java files to the Win95 system and compile them > > there, then again, both the applet and the application run exactly as > > they did under linux. > > > > Why could this be happening? > > If what you claim is true, then this is really worthy of further > investigation. The problem of Java WORA is usually a lot more subtle > then this, it is usually something along the line of slight > differences in behaviour, GUI for example. It shouldn't be as > gross as what you described. > > Ming-Ching Yes, I do notice some slight differences in GUI, but I'm not concerned about those for now. It's really pretty straightforward. The CLASSPATH is not the issue as transferred class files fail but recompiled source succeeds with the same CLASSPATH. I copied the files across using a DOS floppy disk and the linux mcopy program. The files were copied in jar's, first a jar with the class files and then a different jar with the source files. A key clue is this: When we get the NoClassDefFoundError, the class it is looking for is package.1.class. No such class exists, but package. is the class containing the main method.
Re: Write Once Run Anywhere?
Thanks to all who responded to my plea for help with the problem of not being able to run class files generated under linux under Win95, while if the same files were recompiled under Win95, they run fine. However, most of your proposed solutions fall wide of the mark. 1) Classpath is irrelevant since the Classpath under Win95 is the same regardless of whether the copied .class files or newly compiled .class files are run. 2) Many wrote about the difficulties with copying files between the two systems. This is not relevant either, since the files actually copied are jar files containing the class files. This should be equivalent to zipping the files. 3) Others have asked how the files were transferred. My results are the same using binary-mode FTP or passing data by floppy disk. 4) Other points made about 8.3 file names or wrong-case filenames do not seem to apply here either, especially because the means of transmission was a jar file which preserved case names. Now here is a detail that may be more relevant: There are 19 .java files in the package. The compilation under linux is making them into 19 class files. When compiling under Win95, 27 class files are created. Two of these are for non-public classes defined in other java files. The other six files have names like x$1.class where x.java is one of my project files (x.class is also created by the compilation). I don't know what these extra files are for, but the NoClassDefFoundError message is telling me that the class it cannot find is x$1. The extra files do not seem to be required under the linux environment, but they appear necessary under the Win95 environment.
Re: Write Once Run Anywhere?
Rob Nugent wrote: > Are you on JDK 1.1 on your Win95 Box ? > > Try doing a "java -version" on both platforms. If you are trying to run JDK1.1 > compiled code on JDK 1.0 that might cause problems. > > Rob > > -- > > Rob Nugent > Development Manager > UniKix Technologies Europe > [EMAIL PROTECTED] > Tel: +44 (0) 1489 585503 > Fax: +44 (0) 1489 881363 I'm on 1.1.6 on both platforms.
Re: Write Once Run Anywhere?
Nelson Minar wrote: > >However, most of your proposed solutions fall wide of the mark. > > Gee, so sorry. Again, there's no fundamental problem with Linux Java, > the problem is something in your own environment. I'm sure you're right. I was just trying to figure out what that was. > >Now here is a detail that may be more relevant: There are 19 .java > >files in the package. The compilation under linux is making them into > >19 class files. When compiling under Win95, 27 class files are > >created. Two of these are for non-public classes defined in other > >java files. The other six files have names like x$1.class where > >x.java is one of my project files (x.class is also created by > >the compilation). > > The $1 files (and $2, etc) are anonymous classes. If javac on Linux > isn't producing them, something is very strange about your setup. > Maybe they're being placed elsewhere? Hmm. No, they're being produced, all right. And they are in the jar file. I just checked. I wonder why I don't find them on the other end when I unjar everything.
Re: Write Once Run Anywhere? - MYSTERY SOLVED
Steve Cohen wrote: > Nelson Minar wrote: > > > >However, most of your proposed solutions fall wide of the mark. > > > > Gee, so sorry. Again, there's no fundamental problem with Linux Java, > > the problem is something in your own environment. > > I'm sure you're right. I was just trying to figure out what that was. > > > >Now here is a detail that may be more relevant: There are 19 .java > > >files in the package. The compilation under linux is making them into > > >19 class files. When compiling under Win95, 27 class files are > > >created. Two of these are for non-public classes defined in other > > >java files. The other six files have names like x$1.class where > > >x.java is one of my project files (x.class is also created by > > >the compilation). > > > > The $1 files (and $2, etc) are anonymous classes. If javac on Linux > > isn't producing them, something is very strange about your setup. > > Maybe they're being placed elsewhere? > > Hmm. No, they're being produced, all right. And they are in the jar > file. I just checked. I wonder why I don't find them on the other end > when I unjar everything. MYSTERY SOLVED! Jar behaves rather oddly under Win95 and this caused me to become confused. When I unjarred the file under Win95, I looked in the Windows Explorer for the products. I immediately noticed under the directory where I did the unjarring, a new path mirroring the path under linux where the files were created, which contained a bunch of class files. I ALSO noticed some class files in the directory where I did the unjarring, but I assumed that these were from a previous compilation, deleted them, and copied in the ones from the unix-like path. However, this set did NOT include any of the inner classes, the $1, $2 etc. So I now had an incomplete set of files and the program wouldn't run. When I just ran the files that jar unzipped, it all worked fine. Duh. I am wondering, however, why Jar makes this additional mirror of the original directory structure and places in it an incomplete set of files. And one more minor problem: The one difference between the program on the two systems is a JOptionsPane. On the linux side it behaves correctly. On the Win95 side it truncates the message. Is there some way to control this? Thanks again for all your help. Steve
Two questions on Swing:
Here are two questions I've had on swing. One pertains to java-linux, the other doesn't, but you guys have been very helpful to me so I thought I'd ask both. 1) Accessing top level menus via keyboard in Swing. Using Swing 1.0.3 and jdk 1.1.6. I can attach keystrokes to menu items via setMnemonic and this works. When I attach keystrokes via setMnemonic() to top level JMenu, however, the keystroke doesn't work, even though the mnemonicized keystroke does appear in the Menu onscreen. That's under redhat 5.0. If I take the program and run it on Win95 then the key stroke access does work. What's going on here? 2) Is there any way to change the colors of the arrow buttons and thumb in a JScrollBar? I can change everything but that and with the colors I've chosen, they look really stupid. I realize that this probably violates the whole look and feel idea which is so prevalent in Swing, but there ought to be some way to get at these things.
nested classes, packages, and javac depend
I find that I'm unable to get rid of the following errors when I do a javac depend of my whole project: error: File /usr/local/java/xyz/Scheduler.java does not contain nested class xyz.Scheduler. 1 as expected. Please adjust the class path so that the file does not appear in the package xyz. What the hell is this trying to tell me? Of course Scheduler.java doesn't contain the class xyz.Scheduler 1. It contains xyz.Scheduler$1 I've looked and looked. There appears to be nothing wrong with my code. Is this a known bug in javac in jdk 1.1.6? The problem goes away if I compile xyz.java separately, outside of the make -depend framework, and then everything works.
Re: nested classes, packages, and javac depend
David Warnock wrote: > Steve, > > > I find that I'm unable to get rid of the following errors when I do > a > > javac depend of my whole project: > > I have read soimewhere sometime that javac -depend is not reliable. > > Can I suggest you download the JIKES compiler from IBM. It's free, it > runs an order of magnitude faster than JAVAC and so far as I can see > the -depend works. You may want to use the +E compiler switch to get > errors in the same/similar format to JAVAC. > The address is http://www.alphaworks.ibm.com/formula/Jikes/ (it's > available as a link from the blackdown site). > > Dave > > David Warnock > Sundayta Ltd Either this URL is wrong or their server is down. I cannot connect.
Re: nested classes, packages, and javac depend
David Warnock wrote: > > > The address is http://www.alphaworks.ibm.com/formula/Jikes/ (it's > > > available as a link from the blackdown site). > > > Either this URL is wrong or their server is down. I cannot > connect. > > Steve, > > I am pretty sure the url is correct but I also could not connect just > now. As John has said a new version will be available on Monday you > could try again then. Or just in case I got the url wrong I normally > see new versions announced on Cafe au lait at > http://sunsite.unc.edu/javafaq/ > > Dave > > David Warnock > Sundayta Ltd OK, the alphaworks site is now back up. I know people told me to wait until Monday to get the latest but I wanted to try it now. The first error came up because I didn't have the right version of libstdc++ so I got that and jikes could now run. I can see it's much faster. However, it produced this output *** Warning: "/usr/local/java/swing/swing-1.0.3/swingall.jar " is either not a valid zip file or it contains a zip file comment. If it contains a comment, rezip it without the comment... followed by many errors involving the swing components. What does this indicate? I never saw THESE errors with javac.
Sorry, but
I read your README.linux and your strong suggestion to send bugs via the java-linux.org. But when I tried to do as you suggested, subscribe to the list, I get told Host unknown (Name server: java-linux.org: host not found) Has it moved? Since that doesn't work, I will reluctantly ask you the question. Probably you don't know the answer but maybe you can direct me or forward this message to the person who does: I downloaded jdk-sbb-1.1.6-2.1.2glibc.i386.rpm for my RedHat 5.0 system. This system has never had the jdk on it before. I used rpm to install it to the default location. But the symbolic links are all wrong. Every executable (for example, javac) I try to run brings up a message like this: javac was not found in /usr/bin/jdk-1.1.6/../bin/i586/green_threads/javac Fiddling with my path does no good either. How should I best proceed? Steve Cohen
More keyboard problems
I am getting my feet wet with java-linux.
As a first step, I am simply copying code from the disk included with
the book
"Java for C/C++ Programmers" by Michael C. DaConta.
The first "Hello World" program worked okay but the second one,
attached, does not.
On my RedHat 5.0 systems (yes, I've upgraded glibc and ld) the dialog
comes up but no keyboard input shows up. Any idea why?
// gui classes
import java.awt.Frame;
import java.awt.TextField;
import java.awt.Panel;
import java.awt.Button;
import java.awt.GridLayout;
import java.awt.Event;
import java.awt.Color;
import java.awt.Label;
// our book class
import book;
// a utility class
import java.util.Vector;
class bookWindow extends Frame {
TextField title;
TextField author;
TextField publisher;
Vector theBooks;
int currentIdx;
bookWindow() {
super("Book Shelf");
// initialize the growable array
theBooks = new Vector(3);
currentIdx = 0;
Panel centerPanel = new Panel();
centerPanel.setLayout(new GridLayout(0, 2));
centerPanel.add(new Label(" Title"));
centerPanel.add(title = new TextField(20));
centerPanel.add(new Label(" Author"));
centerPanel.add(author = new TextField(20));
centerPanel.add(new Label(" Publisher"));
centerPanel.add(publisher = new TextField(20));
add("Center", centerPanel);
Panel bottomPanel = new Panel();
bottomPanel.add(new Button("store"));
bottomPanel.add(new Button("clear"));
bottomPanel.add(new Button("prev"));
bottomPanel.add(new Button("next"));
bottomPanel.add(new Button("exit"));
add("South", bottomPanel);
move(200, 100);
pack();
show();
}
public boolean handleEvent(Event evt) {
if (evt.id == Event.ACTION_EVENT)
{
if ("store".equals(evt.arg))
{
book aBook = new book(title.getText(),
author.getText(),
publisher.getText());
theBooks.addElement(aBook);
currentIdx = theBooks.size();
return true;
}
if ("clear".equals(evt.arg))
{
title.setText("");
author.setText("");
publisher.setText("");
return true;
}
if ("prev".equals(evt.arg))
{
if (currentIdx > 0)
{
book aBook = (book) theBooks.elementAt(--currentIdx);
title.setText(aBook.getTitle());
author.setText(aBook.getAuthor());
publisher.setText(aBook.getPublisher());
}
return true;
}
if ("next".equals(evt.arg))
{
if (currentIdx < (theBooks.size()-1))
{
book aBook = (book) theBooks.elementAt(++currentIdx);
title.setText(aBook.getTitle());
author.setText(aBook.getAuthor());
publisher.setText(aBook.getPublisher());
}
return true;
}
if ("exit".equals(evt.arg))
{
System.exit(0);
}
}
return true;
}
}
class bookGUI {
public static void main(String args[])
{
new bookWindow();
}
}
Running java binaries under Linux
The file java.txt in the /usr/src/linux/documentation directory gives information on compiling the java kernel to provide support for running java binaries. (This file is in the 2.0.36 source trees and I believe earlier ones as well. It appears to be somewhat out of date. For one thing, it mentions a HOWTO file supposedly available at ftp://sunsite.unc.edu/pub/Linux/docs/HOWTO/Java-HOWTO that wasn't there last I looked. Is this available elsewhere? Or even relevant? It then goes onto define a lot of rigamarole to go through either involving editing the fs/binfmt_java.c source file (no thanks - I'd rather keep my sources clean if I can) or else issuing a command to write something to /proc/sys/kernel/java-interpreter. How the heck do I do this? /proc/sys/kernel is not writable and I cannot make it writable. The chmod command is accepted but does not actually do anything. /proc isn't a real directory anyway, is it? Anyway, does anyone here have the scoop on the real way to set this up. Also, must the java interpreter be a particular directory for this to work?
Wierd results using binfmt_misc
I have recently installed binfmt_misc on my linux system using kernel 2.2.1. I have this game application I've written. It lives in its own package in its own directory one level down from ./usr/local/java. Following the suggestions of people here, I have gotten into the habit of NOT defining classpath variables but using the -classpath switches in javac and java. Therefore I had to rewrite the "javawrapper" that comes as a sample with the binfmt_misc documentation. Now for the wierd part. It all works just fine when I am logged in as root. But when logged in as myself, java reports that it can't find my class. What could cause this? I have loaded up my javawrapper script with a bunch of echo statements and am convinced that it produces the same output under both logins. Neither as root nor as myself do I have a CLASSPATH variable defined. So what else could it be? Or is it just a bad idea to use a package member class as the class holding main()?
Re: Wierd results using binfmt_misc
Michael Sinz wrote: > On Fri, 19 Feb 1999 05:55:52 -0600, Steve Cohen wrote: > > >I have recently installed binfmt_misc on my linux system using kernel > >2.2.1. > >I have this game application I've written. It lives in its own package > >in its own directory one level down from ./usr/local/java. > >Following the suggestions of people here, I have gotten into the habit > >of NOT defining classpath variables but using the -classpath switches in > > > >javac and java. Therefore I had to rewrite the "javawrapper" that comes > > > >as a sample with the binfmt_misc documentation. > > > >Now for the wierd part. It all works just fine when I am logged in as > >root. But when logged in as myself, java reports that it can't find my > >class. What could cause this? I have loaded up my javawrapper script > >with a bunch of echo statements and am convinced that it produces the > >same output under both logins. Neither as root nor as myself do I have > >a CLASSPATH variable defined. So what else could it be? > > Have you checked the access rights of the directories and class files? > Most likely, if you built under root, it does not have world read or > execute on the files and/or directories. (Actually, the .class files > do not need execute but they do need read) > > >Or is it just a bad idea to use a package member class as the class > >holding main()? > > No, I do that all the time. It works well. > > I do not, however, use my system under "root" *except* when absolutely > required (as in, when doing admin work). This is a good habit to be > in since it tends to reduce your chances of really getting messed up > or having some unwanted access into your system. It also helps > identify things like access rights issues in your directories and files > since non-root users actually are held to them. Thanks, it was the permissions, but not because I was using root. I don't normally log in as root but it was necessary for tinkering with the javawrapper script. The permissions were fouled up for a very wierd reason - I had written the code prior to upgrading the system. The upgrade did not go smoothly and somehow my user id # got fouled up. The system didn't consider me the owner even though "I" was the original owner and wrote all the code. However, even so, shouldn't class files as opposed to source files normally be readable by anyone? That was not the case here. My class files seem to be readable only by owner and group, not everyone. > > > Michael Sinz -- Director of Research & Development, NextBus Inc. > mailto:[EMAIL PROTECTED] - http://www.nextbus.com > My place on the web ---> http://www.users.fast.net/~michael_sinz
java question
I realize that this is not the proper forum for this, but I consider this list pretty knowledgeable about java and I just toy around with it at the moment. My employer is working on an application that is deliverable on many platforms, from a standalone win32 platform to client-server versions served everywhere from NT to mulitple flavors of unix (Sun, HP, AIX, etc.) to AS400. The application is written in C and C++. One minor part of this application, for which I have become responsible, delivers a file of updated information to the users via the internet. Once a month, the administrator of the customer system would contact our web site and download the information. However the design is to do it from within our application, not from a browser (just press a button). The thought of programming this connection and the logic behind it (don't download file if already up to date, etc.) on all these platforms is a little daunting, and so tonight, it occurred to me that perhaps this part of the application - contacting the web site and ftping the file - might be doable as a java bean. Offhand, this seems like a great way to make use of the cross-platform capabilities of java. Performance is not an issue. The file is small. My questions are then, 1) are java virtual machines available on the full range of platforms mentioned above? 2) if customers do not have java installed, what runtime licensing issues are there? 3) How difficult and how possible is it to call java beans from C and C++ code on these platforms?
can't find libjava.so
I have installed jdk 1.2 on my redhat 5.2 system and pointed my path at it. When I try to run java, I get the Error can't find libjava.so. I can find this file in jdk1.2/jre/lib/i386. I tried copying it to /lib. That didnt' work. Where is it expecting to find this file? -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: can't find libjava.so
Per Widerlund wrote: > Steve Cohen wrote: > > I have installed jdk 1.2 on my redhat 5.2 system and pointed my path at > > it. When I try to run java, I get the Error can't find libjava.so. > > I can find this file in jdk1.2/jre/lib/i386. I tried copying it to > > /lib. That didnt' work. Where is it expecting to find this file? > > I believe the script is written in such a way that you have to have it in > your path. > > Going to the directory and executing "./java" gives the result you describe, > but executing "java" when it can be found in the path works fine. > > Regards, > > Per Widerlund I don't think that's it. I get these results by executing java when it is found on the path. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: can't find libjava.so
Alvaro del Castillo wrote: > Steve Cohen wrote: > > > I have installed jdk 1.2 on my redhat 5.2 system and pointed my path at > > it. When I try to run java, I get the Error can't find libjava.so. > > I can find this file in jdk1.2/jre/lib/i386. I tried copying it to > > /lib. That didnt' work. Where is it expecting to find this file? > > > > -- > > To UNSUBSCRIBE, email to [EMAIL PROTECTED] > > with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED] > > Hi, > > You have to put in the LD_LIBRARY_PATH the localtion of this library. > I have put in the /etc/ld.so.conf the new line: > > /home/acs/almacen/instalaciones/jdk1.2/jre/lib/i386 > > and all works fine. > > Good Luck > > -- Alvaro This didn't work for me. I tried it (of course changing the path to the location of my jdk1.2). and it continues to fail. Can someone explain What is the deal on libjava.so? -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: can't find libjava.so
Bruno Boettcher wrote: > > > Steve Cohen wrote: > > > > I have installed jdk 1.2 on my redhat 5.2 system and pointed my path at > > > > it. When I try to run java, I get the Error can't find libjava.so. > > > > I can find this file in jdk1.2/jre/lib/i386. I tried copying it to > > > > /lib. That didnt' work. Where is it expecting to find this file? > me too i had to set the LD_LIBRARY_PATH to something like : > /usr/local/src/jdk1.2/jre/lib/i386/green_threads:/usr/local/src > /jdk1.2/jre/lib/i386/classic:/usr/local/src/jdk1.2/jre/lib/i386 > > ciao > bboett > == > acount at earthling net > http://erm6.u-strasbg.fr/~bboett > === > Unsolicited commercial email is NOT welcome at this email address > To contact me replace acount by bboett in above addresses Well, thanks, but this didn't work for me either. Even if it would have worked, this seems like a bug to me. I don't think you should have to go into your shell initialization scripts every time a new version of java comes out.. Where is this LD_LIBRARY_PATH variable documented? Steve -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Understanding 1.2 classpath
I'm having a little difficulty understanding Java 1.2's classpath structure. Sun has a dcoument "Command Line Changes from 1.1 to 1.2". After reading it, I'm even more confused. For one thing, the Sun document mentions a file called rt.jar. I don't find an rt.jar. In the blackdown distribution I find in lib only tools.jar and dt.jar. In any case, I am used to supplying a classpath, via the classpath switch on the command line of : /usr//local/java:/usr/local/java/jdk117_v1a/lib/classes.zip:/usr/local/java/swing/swing-1.0.3/swingall.jar. For execution, it's the same except '.' is prepended. With jdk 1.2 installed in /usr/local/java/jdk1.2 what would be the equivalent classpath to use in 1.2 for compilation? For execution? Thanks. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
javac 1.2 a real pig
both time-wise and memory usage wise. I've had to boost the default heap size to 20 MB. (Possibly this is because I'm compiling with -verbose because I had to see what the heck was taking it so long.) Is a 1.2-compatible jikes available yet? The jikes I used for 1.1.7 seems to zip through the files with its usual speed, but when I go to run the thing I get "NoSuchClassExceptions" in my main class. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: javac 1.2 a real pig
Hani Suleiman wrote: > I use jikes with jdk1.2, the only snag is that you have to explicitly > include rt.jar in your classpath. Also it will compile code that would not > be passed by 1.2 javac. Sorry no specific code to demostrate this (and it > would be long on the jikes mailing list anyways!), but it had to do with > method calls in inner classes. > > At 10:08 AM 3/12/99 -0600, Steve Cohen wrote: > >both time-wise and memory usage wise. I've had to boost the default > >heap size to 20 MB. (Possibly this is because I'm compiling with > >-verbose because I had to see what the heck was taking it so long.) > > > >Is a 1.2-compatible jikes available yet? The jikes I used for 1.1.7 > >seems to zip through the files with its usual speed, but when I go to > >run the thing I get "NoSuchClassExceptions" in my main class. Yes. I am now seeing that the problems I was seeing that I was attributing to jikes are also seen when running the program compiled under javac: More on the slowness of javac: Compilation speed (from scratch building multiple class files for same application: javac: [done in 1009911 ms] jikes: approx 15 seconds. I had previously thought the errors I was getting on execution were the result of using jikes. But apparently not so. Once javac finished its compilation, an identical exception occurred on executing the compiled application: [scohen@stevecoh jahtzee]$ java JahtzeeApp Exception in thread "main" java.lang.NoClassDefFoundError: JahtzeeApp (wrong name: jahtzee/JahtzeeApp) at java.lang.ClassLoader.defineClass0(Native Method) at java.lang.ClassLoader.defineClass(Compiled Code) at java.security.SecureClassLoader.defineClass(Compiled Code) at java.net.URLClassLoader.defineClass(Compiled Code) at java.net.URLClassLoader.access$1(Compiled Code) at java.net.URLClassLoader$1.run(Compiled Code) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Compiled Code) at java.lang.ClassLoader.loadClass(Compiled Code) at sun.misc.Launcher$AppClassLoader.loadClass(Compiled Code) at java.lang.ClassLoader.loadClass(Compiled Code) What is the problem here? This application worked when compiled under JDK117. Perhaps I need to supply classpath to java? Doing it that way yields: [scohen@stevecoh jahtzee]$ java -cp /usr/local/java/ JahtzeeApp Exception in thread "main" java.lang.NoClassDefFoundError: JahtzeeApp without all the further info. Maybe I need to supply the current directory as well? No, doing it that way gives me the same error messages as no classpath at all. [scohen@stevecoh jahtzee]$ java -cp ./:/usr/local/java/ JahtzeeApp Exception in thread "main" java.lang.NoClassDefFoundError: JahtzeeApp (wrong name: jahtzee/JahtzeeApp) at java.lang.ClassLoader.defineClass0(Native Method) at java.lang.ClassLoader.defineClass(Compiled Code) at java.security.SecureClassLoader.defineClass(Compiled Code) at java.net.URLClassLoader.defineClass(Compiled Code) at java.net.URLClassLoader.access$1(Compiled Code) at java.net.URLClassLoader$1.run(Compiled Code) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Compiled Code) at java.lang.ClassLoader.loadClass(Compiled Code) at sun.misc.Launcher$AppClassLoader.loadClass(Compiled Code) at java.lang.ClassLoader.loadClass(Compiled Code) -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
swing changes?
I have ported my application from 1.1.7 to 1.2, and after changing all the com.sun.java to swing gotten the application to compile. It blows up, however, with a null pointer exception, the first time the user presses a button which eventually triggers a call to JComponent.paintAll(). The components were originally painted once, successfully without causing null pointer exceptions so I'm curious what the difference could be. This code gave no trouble in jdk 1.1.7. I have looked at everyplace I could think of on the Sun site documenting changes in API to see if there was anything about this sort of thing and came up empty. It would seem that for something this simple to break it would have to be a major change in the way the whole swing system works. Does anyone have any information on any sort of macro-level changes to swing that could cause this behavior? Or could it be a bug in the linux port? (I don't have a 1.2 platform yet to test the code under Windows, but I will soon.) In any case I have sent a bug report but perhaps someone here has information. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Missing fonts and pointer exceptions
I've seen the reply to msg 540 on the bug system about these missing fonts, suggesting I copy them into my /jre/lib/fonts directory but I don't know where to get these font files. d051.pfb and s051.pfb are not found anywhere on my system. I wonder if this has anything to do with the NullPointerException I've reported previously, since the font messages do occur for me before the exception occurs. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Applet problem
It may be a dumb question, but... I have compiled and build an applet under JDK1.1.6 (Blackdown version) under RedHat Linux 5.0. The compiler gives no errors. With the current directory being the directory where the file XYZApplet.class is and an HTML file with the name XYZ.html in the same directory, containing the following I give the command appletviewer XYZ.html I get the following errors: load: class XYZApplet.class not found. java.lang.ClassNotFoundException: XYZApplet at sun.applet.AppletClassLoader.loadCode(AppletClassLoader.java:385) at sun.applet.AppletPanel.createApplet(AppletPanel.java:462) at sun.applet.AppletPanel.runLoader(AppletPanel.java:398) at sun.applet.AppletPanel.run(AppletPanel.java:237) at java.lang.Thread.run(Thread.java) Why doesn't this work? CLASSPATH shouldn't be an issue as everything is in the current directory. There's no problem running basically the same code as a standalone program with a main. Removing the quotation marks from around the applet name in the HTML file does no good. And it won't load under Netscape either. It is finding the class file: I get a FileNotFound error instead, if I misspell the name of the class file. Thanks for any ideas.
What's up with this?
I realize this may not be the appropriate place for this question but why can't
I do this?
//file a:
import java.awt.*;
public class a {
void paint (Graphics g) {
...
}
}
//file b:
import java.awt.*;
import a;
public class b {
public a A;
...
void paint (Graphics g) {
A.paint(g);
}
}
The compilation of file b fails with an error message about an unknown method
paint( java.awt.Graphics )
WHY? This code compiles fine if it is all in one file
I have a big problem with Sun
Michael Emmel wrote: > It seems that Sun will not support bug reports that occur in the > platform independent > parts of Java since I'm using Linux. If you report a bug and say your > on Linux > they say its not a supported platform. Even though I've been reporting > bugs in the Swing. > > I can't believe Sun forces me to use NT ! > > Anyway just though I'd warn everybody on the list that if you report a > bug don't let them know your on linux > they will drop it. > > Pissed off. > > Mike > > -- > To UNSUBSCRIBE, email to [EMAIL PROTECTED] > with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED] Far be it from me to defend Sun - but - if it's a platform-independent bug, wouldn't you have had to run the code on another platform to verify that it is platform independent? That said, I do agree with you that their excessive delay in answering bug reports is ridiculous. Often I have completely forgotten the problem when I finally hear from them.java It seems that Sun will not support bug reports that occur in the platform independent parts of Java since I'm using Linux. If you report a bug and say your on Linux they say its not a supported platform. Even though I've been reporting bugs in the Swing. I can't believe Sun forces me to use NT ! Anyway just though I'd warn everybody on the list that if you report a bug don't let them know your on linux they will drop it. Pissed off. Mike -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
OT: java and SAMBA
This is slightly off topic as it doesn't involve linux but it involves a
close relative : SAMBA.
I wrote a program that processes a number of files residing in a
directory on an SGI server that was running irix (6.2). Since we don't
have a development environment for irix but do for NT, I thought we
could run the program on NT and access the irix machine via SAMBA -
since SAMBA is running on the machine and the drive in question
DOES appear under NT Explorer.
The directory in question is mapped on NT to the N:\ directory. I can
navigate through this tree with NT without the slightest problem. Yet
when my java program tries to access it (by instantiating a File object
):
File f = new File("N:\\");
if (f.exists())
System.out.println("N:\\ exists");
else
System.out.println("N:\\ does not exist");
if (f.isDirectory())
System out println("N:\\ is a directory");
else
System out println("N:\\ is not a directory");
this is the output:
N:\ exists
N:\ is not a directory
What could be going on here? Why wouldn't the java program see the same
basic attributes of the directory
as NT + Samba?
Anyway, since java is multiplatform, I was able to download the JDK for
irix from SGI and run the program there and it works fine. (Yay, java!)
But this is not the ideal solution and I'd like to understand why I was
having trouble. Can anyone tell me?
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
