 |
 |
Index ‹ java-programmer
|
- Previous
- 1
- cult3d e javaHo compilato un java per usarlo con cult3d ma quando lo chiamo dal cult mi
ritorna questo errore:
java.lang.NoClassDefFoundError
at com/ms/security/SecurityClassLoader.internalDefineClass
at com/ms/security/SecurityClassLoader.defineClass
at com/cult3d/IECult3DClassLoader.loadClass
at com/cult3d/IECult3DMain.event
Succede lo stesso anche se provo a compilare un esempio base di cult, a
questo punto penso di dover cambiare qualcosa nella procedura di
compilazione.
Qualcuno ha gia' sbattuto la testa contro questo errore?
- 2
- Signed applet focus problem,.Hello,
I have a jsp page which contains a signed applet which reads some
System properties.
I am using jdk 1.4.2_06. and IE 6.028.
When the signed certificate appears, if I click on the Internet
Explorer icon in the task bar, the certificate goes below the browser.
Now since the certificate is supposedly modal, My browser loses focus.
ie. I cannot bring the certificate to the front sans tabbing and the
browser will not respond to user input. The only way to get the
certificate to the front is by "tabbing" till I get to it.
Any one seen this behavior before? If so any suggestion would be
appreciated.
Thanks
Karl.
- 3
- Execute jar in program codeI have a jar file, without source code, say abc.jar.
I have set it in the CLASSPATH
The main execute class in abc.jar is a.class.
In the command prompt, I can execute the program by
issuing "java a < someIOfile"
But I would be like to embed it in my program.
Can I create a "dynamic" instance from it?
- 4
- OMLETv4: SPAM SPAM SPAM
--
Daniel A. Morgan
University of Washington
email***@***.com
(replace 'x' with 'u' to respond)
- 5
- How to kill thread which is blocked by Serversocket.accept()?Hi;
I have got a network-thread running in the background listening for
connection-attempts.
The thread uses an instance of Serversocket and its accept() method to
listen.
After a certain period of time i want to kill the thread if no connection is
established.
The problem is: the accept-method blocks until someone connects.
Therefore it is not possible for me to use the interrupted-flag and check it
within a loop in my
thread to signalize it to end (the recommended way to kill a thread). I dont
want to use the thread.stop
() method since it is deprecated, but even when i try to use it i can not
kill the thread.
Within my gui thread i tried to use a swing timer, but it doesnt kill the
thread:
timer = new Timer(TEN_SECONDS, new ActionListener() {
public void actionPerformed(ActionEvent evt) {
if (networkThread.isAlive) {
timer.stop();
networkThread.stop();
//...Update the GUI...
}
}
Anybody there who knows a proper way of killing such a blocked thread?
Thanks in advance,
Jan
- 7
- 8
- awt Dialog color problemHi, I'm using jdk 1.1.8 on an embedded application which runs under Personal
Java on VxWorks (I think). But anyway, that may not matter. I'm displaying
an awt Dialog and the color of the title bar is a pretty ordinary looking
red. I'm guessing this comes from O/S like it would in MS Windows. I have
no access to the operating system to change this. Is there any way to
change system colours in java?
Chris.
- 8
- Dying hype: Slowing sales of iPhone
Well, the hype sure died fast. For those morons who think 700k units
were sold over the weekend - hey idiots, that's an ESTIMATE from one
source, and the most generous one at that. The range of sales
estimates is from 250k to 700k.
In fact, some analysts have downgraded sales projections for next year
from 12 m to 8 million based on the fact that supply seemed to be more
than demand.
think about it morons. ur selling 8 million phones in a 1 BILLION unit
yearly market.
* laughing at the macnut tools who spent lots of money on a smudgy
underwhelming toy (so far), enjoying the nice breeze too
- 8
- Resizing images thru a java program
hi
I need to capture an image based on the URL of the image provided by
the user and do the following things
1. Create a thumbnail
2. Resize the image
I may have to store these two images locally or just recreate these two
images and display it in the browse.
What are the best tools to use to achieve this? I need a Linux/java
based solution. Will Imagemagick.org do the magic?
-- Mahesh
- 8
- Reference sitesDoes anyone have a list of reference websites that are running FreeBSD
and Java?
Or does anyone know of any high volume sites using FreeBSD and Java?
Thanks,
Todd
_______________________________________________
email***@***.com mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-java
To unsubscribe, send any mail to "email***@***.com"
- 9
- Refer to current filename and line.Hi,
I remember this was possible in C with macros. Is it possible in Java
to refer to the current file name and line number as in
System.out.println( something.that.returns.current.file.name() + "
printed this line.");
Many thanks in advance!
Aaron
- 10
- Seeing if a string equals NullHow can you test a string to see if it is null? I have tried the
following code but it throws a nullpointerexception.
for (int i = 0; i < names.length; ++i) {
if (names[i].equals("null")) {
nullcount += 1;
}
- 13
- reference to a jar file inside another jar fileHi, I need create a manifest file for a jar, but I need set the classpath in
the manifest file to reference a jar file inside the current jar file. My
idea is getting a single jar file which contains all the needed jar files.
- 14
- GCJ 4.1 and OpenOffice.orgFWIW, I have been working with Eric Anholt to have Kaffe (java/kaffe)
supported by bsd.java.mk. The only thing with miss is a port of a
Javadoc tool so that ports documentation may be built without any Sun or
IBM JDK. I believe gjdoc (can't remember if this part of classpath or
another "free" Java tool) could be used in place of javadoc.
I'll have a look at your wrapper and modifications in the next few days.
Herve
On Fri, Mar 10, 2006 at 10:59:35AM +0900, NAKATA Maho wrote:
> I believe gcj is now one of the usable Java implementation,
> however there are some small (but tedious) issues must be solved to
> check in to FBSD ports cvs repo.
> I made some ports or updates of ports so that we can at least compile a
> package using Java; OpenOffice.org. I believe with appropreate wrapper,
> we can add gnugcj as _JAVA_VENDOR_LIST in /usr/ports/Mk/bsd.java.mk.
> then we can use/comple Java applications without bootstrapping java/jdk14
> etc.
- 16
- Runtime - external program visibility
Hello,
i use the getRuntime method to start an external program out of
my Java app: Runtime.getRuntime().exec(cmd);
where cmd is an array of String
String[] cmd =
{ "\"c:/Whatever.exe\"","/user=User","/password=XXX"};
Now the issue is that the program (Whatever.exe) starts, it
accepts the parameters (user,password), - the / is required by
Whatever.exe - but the window of the application Whatever.exe is
not visible! The process is there (one can see it in the
taskmanager).
In Delphi i have the possibility by using Windows.CreateProcess
and passing a "StartupInfo"
(lStartupInfo.dwFlags:= STARTF_USESHOWWINDOW;
lStartupInfo.wShowWindow:= SW_SHOWNORMAL;) but here in Java i dont see a possibility of determining in which way the external app is being started up or determining its visibility.
kind regards
Oliver
|
| Author |
Message |
Randy Tingley

|
Posted: 2004-4-3 8:22:00 |
Top |
java-programmer, loading varables
I have a variable "book" which askes the user for four titles which will be
with one patron's name.
How would i load this with a loop?
Some how I am getting lost?
Thank you.
input Patron's name
name = reader.readLine("Enter the first patron's name: ");
patron.setName(p);
for (int i = 1; i <= 3; i++){
Book = reader.readLine("Enter the book's title: ");
Book.setBook(i, Book);
|
| |
|
| |
 |
Randy Tingley

|
Posted: 2004-4-3 8:58:00 |
Top |
java-programmer >> loading varables
"Roedy Green" <email***@***.com> wrote in message
news:email***@***.com...
> On Fri, 2 Apr 2004 19:21:30 -0500, "Randy Tingley" <email***@***.com>
> wrote or quoted :
>
> >I have a variable "book" which askes the user for four titles which will
be
> >with one patron's name.
> >How would i load this with a loop?
> >Some how I am getting lost?
> >Thank you.
>
> First read http://mindprod.com/jgloss/codingconventions.html
>
> It is important for people to understand your code you use caps
> properly.
>
> What type of variable is book? String[] JComboBox, String?
>
> What code you need depends heavily on that.
>
> --
> Canadian Mind Products, Roedy Green.
> Coaching, problem solving, economical contract programming.
> See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
Book is a String
We have two programs and I am trying to code (3rd program) an interface that
will
accept user input. I know that I am a novice and the books that I have all
over
my kitchen table seem to be worthless ...
So far with dozens of attempts ... my efforts have been in vain
|
| |
|
| |
 |
Mike Hoover

|
Posted: 2004-4-3 16:25:00 |
Top |
java-programmer >> loading varables
On the line that reads:
patron.setName(p);
Shouldn't is be:
patron.setName(name);
"Randy Tingley" <email***@***.com> wrote in message
news:email***@***.com...
> I have a variable "book" which askes the user for four titles which will
be
> with one patron's name.
> How would i load this with a loop?
> Some how I am getting lost?
> Thank you.
>
>
> input Patron's name
> name = reader.readLine("Enter the first patron's name: ");
> patron.setName(p);
> for (int i = 1; i <= 3; i++){
> Book = reader.readLine("Enter the book's title: ");
> Book.setBook(i, Book);
>
>
|
| |
|
| |
 |
Randy Tingley

|
Posted: 2004-4-3 19:33:00 |
Top |
java-programmer >> loading varables
I have been attempting to modify this program below to accept user input for
patron's
name and book's title:
public class LibraryTester{
public static void main (String[] args)
{
Patron p = new Patron("Ken Lambert");
Book b1 = new Book("Cider House Rules", "John Irving");
Book b2 = new Book("The Perfect Storm", "Sebastian Junger");
Book b3 = new Book("The Illiad", "Homer");
Book b4 = new Book("Hamlet", "William Shakespeare");
System.out.println(p.borrowBook(b1));
System.out.println(p.borrowBook(b2));
System.out.println(p.borrowBook(b3));
System.out.println(p.borrowBook(b4));
System.out.println(p);
System.out.println(p.returnBook("Cider House Rules"));
System.out.println(p.hasBook("Cider House Rules"));
System.out.println(p.hasBook("The Perfect Storm"));
System.out.println(p);
}
}
**********************************************
to pass data to another two programs, this one is Book:
public class Book {
//instance varibles
private String author, title;
//construction method
public Book()
{
author = " ";
title = " ";
}
//another constructor method - same name
public Book(String author, String title)
{
author = author;
title = title;
}
public String author()
{
return(author);
}
public String title()
{
return(title);
}
public String toString()
{
return("Title: " + title + "\n" + "Author:" +
author);
}
}
****************************************************
And pass to this program Patron:
public class Patron {
//instance varibles
private String name;
private Book Book1, Book2, Book3;
//constructor method
public Patron()
{
name = " ";
Book1 = null;
Book2 = null;
Book3 = null;
}
public void setName(String nm){
//Set a student's name
name=nm;
}
public String getName()
{
return(name);
}
public boolean borrow(Book B)
{
if (Book1 == null)
{
Book1 = B;
return(true);
}
else if (Book2 == null)
{
Book2 = B;
return(true);
}
else if (Book3 == null)
{
Book3 = B;
return(true);
}
else
return(false);
}
public boolean hasbook(String title)
{
if (Book1 !=null)
if
(Book1.title().equals(title))
return(true);
if (Book2 !=null)
if
(Book2.title().equals(title))
return(true);
if (Book3 !=null)
if
(Book3.title().equals(title))
return(true);
return(false);
}
public boolean returnbook(String title)
{
if (Book1 !=null)
if
(Book1.title().equals(title))
{
Book1 = null;
return(true);
}
if (Book2 !=null)
if
(Book2.title().equals(title))
{
Book2 = null;
return(true);
}
if (Book3 !=null)
if
(Book3.title().equals(title))
{
Book3 = null;
return(true);
}
return(false);
}
public String toString()
{
String str;
str = ("Patron's name: " +
name);
if (Book1 != null)
str = (str +
"\n" + Book1);
if (Book2 != null)
str = (str +
"\n" + Book2);
if (Book3 != null)
str = (str +
"\n" + Book3);
return(str);
}
}
//ends patrons class
***************************************************
I have rewritten my LibraryTester at least 11 times in vain.
Any comments will be greatly appreciated.
Thank you.
|
| |
|
| |
 |
Randy Tingley

|
Posted: 2004-4-3 19:47:00 |
Top |
java-programmer >> loading varables
[snip for readablility]
My first 18 - 20 attempts to re-code LibraryTester to accept user input was:
import TerminalIO.KeyboardReader;
import java.text.NumberFormat;
import BreezySwing.Format;
public class LibraryTester {
public static void main (String[] args){
// Instantiate the Patrons & Books and the keyboard
Patron patron1 = new Patron();
Patron patron2 = new Patron();
Patron patron3 = new Patron();
//Book b1 = new Book();
//Book b2 = new Book();
//Book b3 = new Book();
KeyboardReader reader = new KeyboardReader();
String name;
String book;
// Input the first patron's data
name = reader.readLine("Enter the first patron's name: ");
//patron1.setName(name);
for (int i = 1; i <= 3; i++){
book = reader.readLine("Enter the book's title: ");
student1.setBook(i, book);
}
// Input the second patron's data
name = reader.readLine("Enter the second patron's name: ");
patron2.setName(name);
for (int i = 1; i <= 3; i++){
book = reader.readLine("Enter the book's title: ");
patron2.setBook(i, book);
}
// Input the third patron's data
name = reader.readLine("Enter the third patron's name: ");
patron3.setName(name);
for (int i = 1; i <= 3; i++){
book = reader.readLine("Enter the book's title: ");
patron3.setBook(i, book);
}
// Output the three patrons information
System.out.println(patron1);
System.out.println(patron2);
*****************************************
I know that I am missing a piece somewhere. Between my wife complaining the
kitchen table is
cluttered with all my java info, books, print outs, and other research stuff
for the last week, I am starting
to believe that I don't understand how to pass info in java.
Any comments, directions, would be greatly appreciated.
Thank you very much for all those that take a minute to review my kaos.
Randy
|
| |
|
| |
 |
Andrew Harker

|
Posted: 2004-4-3 21:15:00 |
Top |
java-programmer >> loading varables
Randy Tingley wrote:
> I know that I am missing a piece somewhere. Between my wife complaining the
> kitchen table is
>
> cluttered with all my java info, books, print outs, and other research stuff
> for the last week, I am starting
>
> to believe that I don't understand how to pass info in java.
>
> Any comments, directions, would be greatly appreciated.
>
> Thank you very much for all those that take a minute to review my kaos.
>
> Randy
I suggest you start with one class and make that do what you want
rather than trying to integrate all these classes all at once.
For each class write a little test harness and check it out - this
will also help you work out how to create a class, call each method,
etc. Code a bit then test it. Pay attention to things like variable
names, scope etc are correct (also follow Roedy's advice too). Look
at various data structures (eg arrays) and play with those a bit at a
time too.
You could use test classes like JUnit but to start with take advantage
of the fact you can have a 'main' in each class ... eg here is a simple
book demo ...
// file Book.java
public class Book {
private String title;
private String author;
Book(String title) {
this(title, "Unknown");
}
Book(String title, String author) {
this.title = title;
this.author = author;
}
public String toString() {
return "Book:title["+title+"],author["+author+"]";
}
public void setAuthor(String author) {
this.author = author;
}
// this will test out the Book class
public static void main(String[] args) {
Book b1 = new Book("Big words");
System.out.println(b1);
b1.setAuthor("RT");
System.out.println(b1);
// Book[] books = new Book[3];
// books[0] = new Book("One", "Fred");
// books[1] = new Book("Two");
// books[2] = new Book("Three", "Barney");
// following is equiv. to above
Book[] books = {
new Book("One", "Fred"),
new Book("Two"),
new Book("Three", "Barney")
};
for (int i = 0; i < books.length; i++) {
System.out.println(books[i]);
}
}
}
|
| |
|
| |
 |
Randy Tingley

|
Posted: 2004-4-3 21:55:00 |
Top |
java-programmer >> loading varables
"Andrew Harker" <email***@***.com> wrote in message
news:406eb8d1.0@entanet...
> Randy Tingley wrote:
>
> > I know that I am missing a piece somewhere. Between my wife complaining
the
> > kitchen table is
> >
> > cluttered with all my java info, books, print outs, and other research
stuff
> > for the last week, I am starting
> >
> > to believe that I don't understand how to pass info in java.
> >
> > Any comments, directions, would be greatly appreciated.
> >
> > Thank you very much for all those that take a minute to review my kaos.
> >
> > Randy
>
> I suggest you start with one class and make that do what you want
> rather than trying to integrate all these classes all at once.
> For each class write a little test harness and check it out - this
> will also help you work out how to create a class, call each method,
> etc. Code a bit then test it. Pay attention to things like variable
> names, scope etc are correct (also follow Roedy's advice too). Look
> at various data structures (eg arrays) and play with those a bit at a
> time too.
>
> You could use test classes like JUnit but to start with take advantage
> of the fact you can have a 'main' in each class ... eg here is a simple
> book demo ...
>
> // file Book.java
>
> public class Book {
> private String title;
> private String author;
>
> Book(String title) {
> this(title, "Unknown");
> }
>
> Book(String title, String author) {
> this.title = title;
> this.author = author;
> }
>
> public String toString() {
> return "Book:title["+title+"],author["+author+"]";
> }
>
> public void setAuthor(String author) {
> this.author = author;
> }
>
> // this will test out the Book class
> public static void main(String[] args) {
> Book b1 = new Book("Big words");
> System.out.println(b1);
> b1.setAuthor("RT");
> System.out.println(b1);
> // Book[] books = new Book[3];
> // books[0] = new Book("One", "Fred");
> // books[1] = new Book("Two");
> // books[2] = new Book("Three", "Barney");
> // following is equiv. to above
> Book[] books = {
> new Book("One", "Fred"),
> new Book("Two"),
> new Book("Three", "Barney")
> };
> for (int i = 0; i < books.length; i++) {
> System.out.println(books[i]);
> }
> }
>
> }
>
>
Thank you! I will try this.
Randy
|
| |
|
| |
 |
Randy Tingley

|
Posted: 2004-4-4 0:34:00 |
Top |
java-programmer >> loading varables
"Randy Tingley" <email***@***.com> wrote in message
news:email***@***.com...
>
> "Andrew Harker" <email***@***.com> wrote in message
> news:406eb8d1.0@entanet...
> > Randy Tingley wrote:
> >
> > > I know that I am missing a piece somewhere. Between my wife
complaining
> the
> > > kitchen table is
> > >
> > > cluttered with all my java info, books, print outs, and other research
> stuff
> > > for the last week, I am starting
> > >
> > > to believe that I don't understand how to pass info in java.
> > >
> > > Any comments, directions, would be greatly appreciated.
> > >
> > > Thank you very much for all those that take a minute to review my
kaos.
> > >
> > > Randy
> >
> > I suggest you start with one class and make that do what you want
> > rather than trying to integrate all these classes all at once.
> > For each class write a little test harness and check it out - this
> > will also help you work out how to create a class, call each method,
> > etc. Code a bit then test it. Pay attention to things like variable
> > names, scope etc are correct (also follow Roedy's advice too). Look
> > at various data structures (eg arrays) and play with those a bit at a
> > time too.
> >
> > You could use test classes like JUnit but to start with take advantage
> > of the fact you can have a 'main' in each class ... eg here is a simple
> > book demo ...
> >
> > // file Book.java
> >
> > public class Book {
> > private String title;
> > private String author;
> >
> > Book(String title) {
> > this(title, "Unknown");
> > }
> >
> > Book(String title, String author) {
> > this.title = title;
> > this.author = author;
> > }
> >
> > public String toString() {
> > return "Book:title["+title+"],author["+author+"]";
> > }
> >
> > public void setAuthor(String author) {
> > this.author = author;
> > }
> >
> > // this will test out the Book class
> > public static void main(String[] args) {
> > Book b1 = new Book("Big words");
> > System.out.println(b1);
> > b1.setAuthor("RT");
> > System.out.println(b1);
> > // Book[] books = new Book[3];
> > // books[0] = new Book("One", "Fred");
> > // books[1] = new Book("Two");
> > // books[2] = new Book("Three", "Barney");
> > // following is equiv. to above
> > Book[] books = {
> > new Book("One", "Fred"),
> > new Book("Two"),
> > new Book("Three", "Barney")
> > };
> > for (int i = 0; i < books.length; i++) {
> > System.out.println(books[i]);
> > }
> > }
> >
> > }
> >
> >
> Thank you! I will try this.
> Randy
>
>
I think I got it!
Thank you very much!
|
| |
|
| |
 |
Andrew Thompson

|
Posted: 2004-4-4 15:25:00 |
Top |
java-programmer >> loading varables
On Sat, 3 Apr 2004 08:55:16 -0500, Randy Tingley wrote:
> ..Between my wife complaining the
> kitchen table is
> cluttered with all my java info,
And our group is becoming cluttered with
your untrimmed replies, 85 lines for your
last reply to say 'thank you', is ridiculous.
Please use the 'delete' key before responding..
<http://www.physci.org/kbd.jsp?key=del>
--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology
|
| |
|
| |
 |
Randy Tingley

|
Posted: 2004-4-4 20:44:00 |
Top |
java-programmer >> loading varables
>
> And our group is becoming cluttered with
> your untrimmed replies, 85 lines for your
> last reply to say 'thank you', is ridiculous.
>
> Please use the 'delete' key before responding..
> <http://www.physci.org/kbd.jsp?key=del>
>
> --
> Andrew Thompson
> http://www.PhySci.org/ Open-source software suite
> http://www.PhySci.org/codes/ Web & IT Help
> http://www.1point1C.org/ Science & Technology
Do you grip all the time?
First to you bring to my attention that I am top posting.
I read your link and made sure that I did not do that again.
Next you told me that when replying I, "cut" or "snipped" to
much of the text out. Now people couldn't see all the question.
Now you are telling me that I am not cutting out enough?
once again you attached a link for me to review.
This newsgroup has taught me alot of valuable information
on java programming that I can not get from any book. This to
me is a "priceless" newsgroup.
I am trying to gain the knowledge that these wonderful people are
willing to share, along with learning this group's rules. I looked in
this group for FAQ's, but there are none?
Thank you, for all that ARE assisting me in my quest for knowledge.
|
| |
|
| |
 |
| |
 |
Index ‹ java-programmer |
- Next
- 1
- Using Netbean IDE for writing/compiling/debugging apps without using ProjectHi
Is there a way to configure Netbean IDE such that it does not insist on
creating a Project everying time I want to use it to
write/compile/debug small Java apps I am writing to learn Java.
I find that default Netbean IDE behaviour to insist on a Project before
I can create a Java file for sample learning applications makes it very
complicated for me as a Java beginner.
Thanks
Bob
- 2
- JMF on pocket pcI wrote an application for my iPAQ, and use JMF cross-platform
version, with Jeode, to playback a file.wav, but when the application
starts, the console shows these errors :
at com.sun.media.renderer.audio.JavaSoundRenderer.initDevice()
at com.sun.media.renderer.audio.JavaSoundRenderer.open()
at com.sun.media.BasicRendererModule.doPrefetch()
at com.sun.media.BasicTrackControl.prefetchTrack()
at com.sun.media.PlaybackEngine.doPrefetch1()
at com.sun.media.PlaybackEngine.doPrefetch()
at com.sun.media.PrefetchWorkThread.process()
at com.sun.media.StateTransitionWorkThread.run()
Why???
- 3
- JBoss startup exceptionsI am getting exceptions when starting the JBoss server. I believe I
have set the environment up correctly. The webserver brings up the
homepage but I can't get to the jmx-console. Has anyone else had this
problem and is there something obvious I've missed?
I'm running on tru64 unix 4.0f with JDK1.4.2. Trying to install jboss
4.0.2
- 4
- Easy way to display JSP source on webI need an easy way to display JSP source in a
web page.
If I use..
<jsp:include page="/test/index.jsp" ></jsp:include> or
<%@ include file="/test/index.jsp" %>
..the jsp I want to include is merged with the
original page and (usually) throws exceptions.
Is there any way to include a jsp in a web page
but have it treated as if it were text?
- 5
- Be Honest: Do you implement hashCode(), equals(), and toString() for every class you write?Patricia Shanahan wrote:
[me:]
> > /Anything/ would be better than that. Throw a runtime exception -- at
> > least that would guarantee that you weren't depending on having a
> > working hashCode() without realising it.
>
> It is a functionally correct hashCode.
Only in the minimal sense that it abides by its contract. It not, however,
useable for anything; therefore it only exists (or should only exist) as a
placeholder for a method which the author assumes will not be needed. But
that's a major risk -- sooner or later someone else is likely[*] to start using
these things in HashTables, and then they get poor performance without knowing
why (or perhaps even without realising that they are getting unecessarily poor
performance). If the assumption is that the method is only a placeholder, then
it would be much safer (as I said) to throw an unchecked exception.
If any programmer /I/ worked with was in the habit of leaving these little
timebombs ticking away in the codebase, then I'd be inclined to throw a Very
Serious Wobbly.
What you think of a programmer who habitually wrote:
void toString() { return ""; }
? Yet that's a damn sight safer (and no less "reasonable") than always
returning zero from hashCode().
> I assume that if Mark found poor hash table performance during
> profiling,
As an aside, profiling is not a good tool for recognising or diagnosing poor
hashing functions. And, although it is a reasonable tool for confirming that a
non-too-special hash function is "good enough", even that is somewhat unsafe
unless you know that your test data is representative of real world data /in
the way it interacts with the hash/.
-- chris
[*] "likely" assuming normal operation of Sod's Law.
- 6
- OutOfMemoryException With XML DOMMy project uses XML for its data files and I am using a DOM parser
(the one native to the JDK) to parse out the files. DOM is especially
useful because the project lends itself to the use of trees.
Unfortunately, there tends to be a limit as to how big the XML files
can be before the DOM parser starts chewing up memory and, if the file
is big enough, I get an OutOfMemoryException. It's not from the
project specifically - it's instead a result of the enormous amount of
space DOM takes up.
I was wondering if there's a solution to this? I have read about SAX
a bit, and although it would fix the OOMEx. it would make it more
difficult to manage the tree structure. I could also increase the
amount of RAM available to the JRE, but I'd rather do that as a last
resort.
Does anybody have any other suggestions? Thanks.
- 7
- newbie scrollbar questionI have a JTextArea wrapped in a JScrollPane, and when I append a line
to the text area
I want the scroll bar to adjust so that the new line is seen in the
viewport. I have
some code that seems to work most of the time, but every once in a
while it does
not work properly. I think I'm probably not doing this the right way.
Here's a code
snippet that shows what I'm doing:
JPanel consolePane = new JPanel();
JTextArea consoleTextArea = new JTextArea(35, 65);
JScrollPane consoleScrollPane = new JScrollPane(consoleTextArea);
JScrollBar vsb = consoleScrollPane.getVerticalScrollBar();
When I want to update the text I do this:
consoleTextArea.append(line);
consoleTextArea.append("\n");
vsb.setMaximum(vsb.getMaximum()+1);
vsb.setValue(vsb.getMaximum()+1);
Seems like there must be an easier way to do this. Is there some
attribute that
I can set that will make this happen automagically?
TIA!
-larry
- 8
- UML Eclipse PluginDoes anyone know a Eclipse plugin that generates a UML diagram out of java code
Thanks
Felix
- 9
- Which executable is used to run Java applets ?When a webpage attempts to run an applet, which executable on my
computer gets launched? Is it "java.exe"?
My reason for this question is that my browser (Mozilla 1.4)
apparently doesn't offer the option to refuse to run Java applets.
So I searched for every occurrence of "java.exe" on my hard-drive
and renamed all of them to something else.
I even re-booted the computer afterwards and then cleared
the browser's cache.
When I went back to a website that runs applets, it took a while
but finally did run the applet, as evidenced by that
familiar coffee-cup icon in the system tray.
So could it be that "java.exe" is not the executable called to run
Java applets? If not, which one would it be?
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
- 10
- To wrap or not to wrap?Hi,
In my personal development efforts, I frequently wrap basic java
functionality. For example, I have a
String MyIO.urlToString(String url)
or
byte[] MIO.urlToBytes(String url)
etc. These functions catch exceptions and return null if something
goes wrong. I have other functoins that, for example, load database
queries into maps.
My gereneral questions are these. Does everybody pretty much end up
writing convenience wrappers like these for themselves?. If yes, why
aren't utilities like these commonly available as more or less
standard libraries? And if no - why not? Is it a bad idea to use these
and is it for some reason better to, e.g., always form URL's, open
connections, capture exceptions, etc.
Thanks for your opinions!
Aaron
- 11
- errors within constructorHi I am working on a project and I am getting an error that I do not
understand.
I have the part of the code below along with the line that gives error.
From the exception message I can assume that the object I pass to the
HashMap is a null object but in the code below I create a new object and
initialize it.
I appreciate any advice.
// group IP address
private static final String MULTGRP = "225.4.5.6";
private InetAddress group = InetAddress.getByName(MULTGRP);
private static HashMap mapGroupSocket = null;
// constructor
public IRCServer()throws IOException{
// create sockets for all groups.
MulticastSocket mcastCsci5431 = new MulticastSocket(CSCI5431_PORT);
mcastCsci5431.joinGroup(group);
// other code (not relevant)
mapGroupSocket.put(CSCI5431, mcastCsci5431); <---- exception
thrown.
}
Error:
Exception in thread "main" java.lang.NullPointerException
at IRCServer.<init>(IRCServer.java:91)
at IRCServer.main(IRCServer.java:105)
- 12
- Non-blocking method for reading writing objects to socketsThe methods writeObject and readObject of socket class are blocking
one. i.e. if we create a ObjectInputStream object using
new ObjectInputStream(socket.getInputStream()), the methods blocks
until it gets some stream stuff.
What is the corresponding non-blocking mthod so as to include in
non-blocking programming?
- 13
- commons and log4j initializing in other web server applicationsThe webserver in my sandbox has about 20 web applications which start
up at runtime.
I'm developing one application in particular.
The web server has classpath which includes a jar file which has a
log4j.properties file.
Several applications up before the one I'm working on.
I can tell that the other applications are finding the log4j.properties
file in the
server classpath - because if I remove it from the jar in the classpath
messages display which warning that log4j hasn't been properly
initialized.
...
My application has a start up servlet the following line of code :
org.apache.log4j.Logger rootLogger =
org.apache.log4j.LogManager.getRootLogger();
rootLogger.setLevel(org.apache.log4j.Level.DEBUG);
The idea is to set the logging level for the application in the start
up servlet.
I'm certain this code gets called. Also, a log4j.properties file and a
log4j.jar
file exists in the application's WEB-INF/lib and WEB-INF/classes
directories.
I have another class in the same application with the line of code :
private static final org.apache.commons.logging.Log LOG =
LogFactory.getLog(JdbcDAO.class);
Note that commons logging is supposed to use log4j when it finds a
log4j.properties file in the classpath.
This LOG variable always has the settings associated with the
log4j.properties
file in the classpath. Or some defaults it sets on it's own when
starting up
with no log4j.properties file.
In other words the code in the start up servlet to set the log level
isn't doing anything.
It appears that there's nothing I can do to initialize the logging
level in my application.
Note that the application this clip of code in the application
weblogic.xml file :
<container-descriptor>
<prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor>
But that hasn't helped here.
Has anyone else ran into this issue and figured out a way to resolve
it?
- 14
- advanced Font renderingHello,
from Photoshop I'm used to be able to define the space between two
characters. So I can generate something like
T E X T
without having to put the blanks in there on my own. This setting can
also be used to put the characters closer to each other, so the
characters might be overlapping.
Is there an option in the Font-classes of awt to achieve the same
result? On the one hand I haven't found something yet, but on the other
hand I'm not really sure what to look for.
Regards
Marten
- 15
|
|
|