 |
 |
Index ‹ java-programmer
|
- Previous
- 2
- Java programmer Job openingInternational company has 2 job openings for Java programmers. Requirements:
3 years experience java programming, self-sufficient, responsible, able to
lead extremely important projects, knowledge of unix/linux. Workplace
Lisbon. Great career opportunity.
Send applications to Filipe Mendes, email***@***.com
- 3
- JTextPane: Workaround for invisible text with hanging indents?Hi all,
I have a hanging indent requirement for paragraph formatting:
<http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/text/StyleConstants.html#FirstLineIndent>
"The amount of space to indent the first line of the paragraph. This value
may be negative to offset in the reverse direction. The type is Float and
specifies the size of the space in points."
A search of Sun's bug database for [set]FirstLineIndent indicates that Sun
has fixed a number of bugs related to rendering negative first line
indents. Does the code I've written below demonstrate another rendering
bug? I'm typing invisible text on multiple platforms with the latest
stable JDK and Mustang beta:
import java.awt.*;
import javax.swing.*;
import javax.swing.text.*;
public class InvisibleText extends JFrame {
public InvisibleText() {
JTextPane tp=new JTextPane();
SimpleAttributeSet attrs=new SimpleAttributeSet();
StyleConstants.setFirstLineIndent(attrs, -150.0f);
StyleConstants.setLeftIndent(attrs, 150.0f);
tp.setParagraphAttributes(attrs, true);
JScrollPane sp=new JScrollPane(tp);
sp.setPreferredSize(new Dimension(300, 200));
getContentPane().add(sp);
}
public static void main(String[] args) {
InvisibleText frame=new InvisibleText();
frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
While typing text finally appears at the left indent position of
subsequent lines.
Assuming my code correctly invokes this API, can anyone come up with a
workaround to make the text appear while it is typed?
Many thanks,
Adam
- 4
- Java Object Persistence (JSP & Java)Hi all.
I'm currently working on a simulation with a web frontend. The
simulation is based on 3 components:
- A Webfrontend
- A persister (which is the object of my quetsio :-)
- A WorkHorse
The Workhorse is doing the actual simulation while the web frontend is
used to interact with the Simulation (queueing and dequeueing new
events to the simulation stack).
Now my question is what the best choice for the persister would be.
I found http://www.prevayler.org/wiki.jsp which looks nice but I don't
know if it's the best choice. Is there a library that transparently
saves and loads whole Object dependencies from an SQL Database, or is
an Object Cloud better?
What is your experience with this/other libraries?
- 5
- JRE versionsWe have in our company several applications that require JRE to work.
They have been developed by different people and some require specific
versions of Java to work correctly.
Normally the applications work well individually but sometimes, when we
need to work with some of them that require different JRE versions, we
are in trouble.
How can we deal with this problem? Why last versions of JRE are not
full compatible with the previous ones?
Greetings,
Samu
- 5
- IDE for Java?I downloaded the Sun product, and find it feature rich but slow. Can someone
recommend a more basic (freeware) IDE which will help a newbie without
hiding every bit of code? I can program my way out of a wet paper bag in a
few languages, but want to by-pass some of the learning curve for this
project.
- 7
- paintImmediately()Is there a reason NOT to use paintImmediately()? It seems to solve a
problem that I've been having with repaint(), but it seems like this
is too easy a solution. Am I looking a gift-horse-in-the-mouth, or is
there some "gotcha" that I haven't run into yet?
Thanks
tom
- 7
- Inline bytecode?Is it possible to do iline bytecode in Java? Sort of like inline asm
in c++, but platform independent.
- 8
- Could you write this sound applet?As a start, consider this simple QBASIC program that generates random
frequencies:
10 frequency = 40 + 400 * RND
20 SOUND frequency, 7
30 GOTO 10
That's fine - except that it plays over the PC speaker - the one that's
just there for the happy beep - and not through the sound card and
proper speakers. You can't control volume, either.
I wonder if anyone would be kind enough to translate the above three
line program into a Java applet. I would like to see whether it looks
simple enough for me to cope with.
If it looks as if I could cope with Java, I would then learn it, and try
to program a way of generating sounds from a mathematical sequence or
formula.
--
Chris
- 8
- Beginner question about JDO best practiceDear all,
this is the first time I'm using JDO/ORM (the JPOX implementation) and
so have a question about best practice.
Let's assume we have a class "Tag" with the only property "String
name" and according setters and getters. The related table has two
columns "PRIMARY BIGINT tag_id" and "UNIQUE VARCHAR name". Note that
the column "name" is unique.
Let's further assume that we manually create some Tag objects during
application runtime. We now want to persist these objects but we don't
care if they are already persisted in the database. If this is the
case, JDO should just attach the object to the database instance. What
is the best practice to accommodate this? Do I have to manually check
every object for existence first? I would like to avoid this.
Let's say the tag "coffee" is already available in the database. I'm
looking for something which works like this:
--8<-snip->8--
Tag tag1 = new Tag( "java" );
Tag tag2 = new Tag( "means" );
Tag tag3 = new Tag( "coffee" );
// no problem
pm.makePersistent( tag1 );
// no problem
pm.makePersistent( tag2 );
// throws SQLException DUPLICATE KEY but should just attach/update
tag3 to database instance
pm.makePersistent( tag3 );
--8<-snip->8--
Thanks for any hint!
- 10
- "class not found".I'm getting the dreaded "class not found" error. I've Googled this
error and found that it's quite common, but not in exactly the way I
get it. My applets run fine on my machine, both when tested locally
via a local HTML file, and also when going to website, but gives the
"Class not found" error other machines. Anyone have any idea what
might be wrong?
I suspect it may be a codebase error, but I've tried the following in
my HTML file without success:
<APPLET CODE="moonCalendar.class"
name = "moonCalendar" WIDTH=1000 HEIGHT=350>
<APPLET CODE="moonCalendar.class" codebase="."
name = "moonCalendar" WIDTH=1000 HEIGHT=350>
<APPLET CODE="moonCalendar.class"
codebase="http://www.ckolchak.com"
name = "moonCalendar" WIDTH=1000 HEIGHT=350>
You can see if it works on your machine by going to:
http://www.ckolchak.com/astroCalendar.htm
- 10
- Javaws.exeI was shocked to notice that Javaws.exe has devolved. It is no longer
an end user tool to manage jawaws apps.
IIRC you used to be able to put a file on the command line. Now you
need a weird URL file://localhost/E:/mindprod/webstarts/esper.jnlp
Anyway you used to be able to launch from the GUI.
--
Bush crime family lost/embezzled $3 trillion from Pentagon.
Complicit Bush-friendly media keeps mum. Rumsfeld confesses on video.
http://www.infowars.com/articles/us/mckinney_grills_rumsfeld.htm
Canadian Mind Products, Roedy Green.
See http://mindprod.com/iraq.html photos of Bush's war crimes
- 10
- Java and avoiding software piracy?On Jul 23, 6:12 am, "Dag Sunde" <email***@***.com> wrote:
> Oh, for God's sake stop it already!
>
> Twisted/nebulous99 is a well-known [insult deleted].
Your claims are incorrect.
> I am really suprised[sic] that the reasonably sensible Java community
> haven't just [death threat deleted]
You are under arrest. You have the right to remain silent. Anything
you say can and will be used against you in a court of law. You have
the right to an attorney. If you cannot afford an attorney, one will
be appointed to you at no cost.
You will confine yourself to your current workstation area until
police arrive. Law enforcement has been notified of your illegal act
and should appear shortly to take you into custody.
- 11
- Linux/X-Windows unable to set focus on a modal form (Consulting $ anyone)It appears whenever a modal window is opened on Linux X-Windows the
focus is stolen from the window and you CANNOT use the keyboard or any
peice of code to return focus to the form - let alone set the focus in
the textbox.
This is not just for my modal forms but for something as fundamental
as JOptionPane or simple code like this:
JFileChooser chooser = new JFileChooser();
if (chooser.showOpenDialog(parentComponent) ==
JFileChooser.APPROVE_OPTION) {
}
From trolling through posts I can see no answers which is really sad
for Linux good for Microsoft I guess. How can we deploy on Linux if
you are forced to get carpal tunnel clicking on every form with the
mouse ?
I would be willing to pay some consulting dollars to get this
resolved.
Greg
- 14
- File Persistence In the Session ObjectI am developing a Struts1.1 based application, that returns an Excel
File generated by Jakarta's POI classes. One of the requirements is
that the file be stored in the SESSION ONLY, not on the file system.
Is this even possible? Doesn't a file need to be physically present
before a reference to it can be stored in the session?
prompt insight would be most appreciated, as I'm working against a
deadline.
Thanks!
PK
- 15
- ports/69675: Eclipse slow typingSynopsis: Eclipse slow typing
Responsible-Changed-From-To: freebsd-ports-bugs->java
Responsible-Changed-By: ijliao
Responsible-Changed-When: Wed Jul 28 02:09:00 GMT 2004
Responsible-Changed-Why:
over to maintainer
http://www.freebsd.org/cgi/query-pr.cgi?pr=69675
_______________________________________________
email***@***.com mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-java
To unsubscribe, send any mail to "email***@***.com"
|
| Author |
Message |
Patricia Shanahan

|
Posted: 2008-4-7 21:05:00 |
Top |
java-programmer, pass by reference
Andreas Leitgeb wrote:
> Patricia Shanahan <email***@***.com> wrote:
>> The issue is more critical for people for whom "pass by reference" is
>> familiar language. They will think they know what it means, and have to
>> find out somehow that it means something entirely different, when
>> talking about Java, that it does when talking about other languages.
>
> By the way, this is also true for "reference" itself. They also have
> to learn that what Java calls a reference wouldn't be called that way
> in other languages, for exactly the reasons you wrote (null allowed,
> assignment-semantics).
Indeed, I think the choice of "reference" to mean "pointer or null" was
a bad one. It would have been better to call a pointer a pointer, and
note that it can be null.
For the benefit of people transitioning from C or C++, it may be
necessary to note that it does not have pointer arithmetic or unsafe
conversions.
> Why is it ok, to talk of references in Java, but have an entirely
> different meaning of "reference" in mind in context of the phrase
> "pass by reference"?
"pass by reference" (or more usually "call by reference") is a long
standing term with a meaning independent of the use of "reference" as a
freestanding term. I learned it long before I knew any language in which
one could actually have a reference. I don't see any reason why having
to learn a Java-specific meaning of reference should require people to
learn special meanings of other terms, especially when with have a
perfectly good phrase, "pass reference by value", that is only one word
longer and says *exactly* how Java behaves.
Patricia
|
| |
|
| |
 |
Patricia Shanahan

|
Posted: 2008-4-7 21:05:00 |
Top |
java-programmer >> pass by reference
Andreas Leitgeb wrote:
> Patricia Shanahan <email***@***.com> wrote:
>> The issue is more critical for people for whom "pass by reference" is
>> familiar language. They will think they know what it means, and have to
>> find out somehow that it means something entirely different, when
>> talking about Java, that it does when talking about other languages.
>
> By the way, this is also true for "reference" itself. They also have
> to learn that what Java calls a reference wouldn't be called that way
> in other languages, for exactly the reasons you wrote (null allowed,
> assignment-semantics).
Indeed, I think the choice of "reference" to mean "pointer or null" was
a bad one. It would have been better to call a pointer a pointer, and
note that it can be null.
For the benefit of people transitioning from C or C++, it may be
necessary to note that it does not have pointer arithmetic or unsafe
conversions.
> Why is it ok, to talk of references in Java, but have an entirely
> different meaning of "reference" in mind in context of the phrase
> "pass by reference"?
"pass by reference" (or more usually "call by reference") is a long
standing term with a meaning independent of the use of "reference" as a
freestanding term. I learned it long before I knew any language in which
one could actually have a reference. I don't see any reason why having
to learn a Java-specific meaning of reference should require people to
learn special meanings of other terms, especially when with have a
perfectly good phrase, "pass reference by value", that is only one word
longer and says *exactly* how Java behaves.
Patricia
|
| |
|
| |
 |
Andreas Leitgeb

|
Posted: 2008-4-7 21:58:00 |
Top |
java-programmer >> pass by reference
PreScriptum: By now, I've read most of the later posts, and my
focus has moved from insisting to use "by ref" in java-context
to understanding the technical difference in detail.
Chris Smith <email***@***.com> wrote:
> ... Pass by reference is a concept that has a particular meaning,
> independent of any other use of the word "reference" in a language.
> [...]
Then either the word "reference" also needs a particular meaning, or
the "pass by ref" is a cyclic definition, based on a meaning of
"reference" that is derived from that concept...
Most seem to agree to that whatever a reference actually is, it must
be one that references the *variable* (or lvalue) that was passed to
it. Also the non-null-ness of a reference seems to be quite agreed
on here.
I want to understand the crucial difference between C++'s
way and Java's way in those special situations, where their
technical effect coincides. There are of course other situations
where the difference is obvious, but I want to understand those
where it isn't.
If in C++ I've got a reference-parameter in a function f1, and pass this
reference(which refers to a real variable one call-level upstairs)
to another function f2 (again, by ref), then obviously f2 may modify
the actual variable two levels up (which was passed to f1), and *not*
modify the *reference* that lives in f1 and still refers to the actual
object "var" in the upper level, afterwards.
If there's a thinko in this paragraph, please point it out.
If it's just unclear, see the following C++ code snippet.
struct mystruct { int i; } var;
void f2(mystruct& x2) { x2=*(new mystruct()); }
void f1(mystruct& x1) { f2(x1); } // <--- x1 is not changed, only var is.
int main() { f1(var); }
* Is the call to f2 from within f1 really "by reference" ?
* Is "x1" (as argument to f2) actually an lvalue ?
If "x1" is just "seen" as an lvalue identical to "var", then
why cannot a java ref be "seen" as "identical" to the object
it points to? Just because it can be null?
f1(*(mystruct*)0); // is compileable! the inevitable runtime SIGSEGV
// only happens inside f2 at the assignment,
// f1 has no problem with a null-reference.
Just because Java-refs can be re-targetted by assignment?
Java's "." operator corresponds to C's "->" or: jRef.xyz == (*cPtr).xyz
If Java had an operator to tell an Object (addressed through the java-ref)
to assume another object's value (as happens when assigning to a C++
reference), would it do "pass by ref", then? IOW: does the difference
lie in the semantics of assignment?
> i.e., a reference in C++ is simply another symbol, with a possibly different
> scope, that denotes the same object as the symbol it is initialized from.
int x[10]; for (int i=0; i<10; i++) { int &j=x[i]; j=42; }
Ref j doesn't need to be initialized from a symbol.
As I've tried to show, most of the artefacts that are used to
disprove java's passing by reference, can be mimicked in C++
as well. The resolution of this contradiction can be either,
that "passing by ref" depends on more than just a method's
signature, or, that Java at least approaches some effects of
pass-by-ref quite closely.
|
| |
|
| |
 |
Arved Sandstrom

|
Posted: 2008-4-7 22:06:00 |
Top |
java-programmer >> pass by reference
"Peter Duniho" <email***@***.com> wrote in message
news:email***@***.com...
> On Sun, 06 Apr 2008 14:04:53 -0700, Andreas Leitgeb
> <email***@***.com> wrote:
>
>> [...]
>> There are times for exact language, and times where focus is on
>> other aspects. That's the other level I've kept mentioning.
>
> I really don't understand how you can, in a thread named "pass by
> reference", think that using the imprecise form of communication makes any
> sense whatsoever.
Mainly because very early in this thread one poster very clearly said:
"In java, all objects are passed by reference.
Basic data types like int, long, boolean are passed by value. Object
variables are always references to an object, and the reference is passed
"by value" as the basic data types, but it is a reference, so..."
Note the first sentence. You certainly can't say Java objects are passed by
value either.
Point being, and I made another recent post to this effect, very many people
do understand the distinction between pass by value and pass by reference,
but also call "passing a pointer by value" passing by reference. You can
call this imprecise...me myself, if I am satisfied that the person actually
understands that they are passing a pointer by value, and not a true
reference, don't lose sleep if they use the term "pass by reference".
Because what they mean is that they have a reference (a
pointer/handle/thingamajiggy) that points to the thing they want to access.
Not a C++-style reference, but a reference.
But when talking to Java folks I'll be very careful from now on. :-)
AHS
|
| |
|
| |
 |
Andreas Leitgeb

|
Posted: 2008-4-7 22:18:00 |
Top |
java-programmer >> pass by reference
Andreas Leitgeb <email***@***.com> wrote:
> PreScriptum: By now, I've read most of the later posts, ...
Sidenote: of course I didn't travel to future :-)
I meant "later than this somewhat aged posting that I
was answering only now"...
|
| |
|
| |
 |
Arved Sandstrom

|
Posted: 2008-4-7 22:24:00 |
Top |
java-programmer >> pass by reference
"Stefan Ram" <email***@***.com> wrote in message
news:email***@***.com...
> Patricia Shanahan <email***@***.com> writes:
>>Remember you are discussing the subject "pass by reference" in a
>>newsgroup that includes people who are trying to learn how Java
>>parameter passing behaves.
>
> Let me add two quotations to this thread:
>
[ SNIP Gosling's quotation ]
> 籧all by reference A call in which the calling module
> provides to the called module the addresses of the
> parameters to be passed.?(15.06.08)
>
> 籧all by value A call in which the calling module provides
> to the called module the actual values of the parameters
> to be passed.?(15.06.09)
>
> ISO 2382-15, Information technology-Vocabulary-Part 15: Programming
> languages
>
> What the quotation from ISO 2382-15 calls 籶arameters?is
> being called 籥rguments?in Java.
This is all well and good. In practise what happens is that very many
programmers also take the case in which the parameter is a pointer, and the
value of that pointer is passed by value, to be call by reference. Not all
of those programmers understand that it's not call by reference in the true
sense, but enough of them do.
It's simply that there are several usages of the word "reference", and you
can't say that either is incorrect. In one sense a "reference" is a
handle/pointer to the thing of interest. IOW, I am calling by value, but I
still have a "reference" to the primitive/object that I wish to access
(including modify in the caller).
So far in this thread I haven't seen very many people contradict the fact
that Java is passing everything by value, in a technical sense. Some of us
are merely pointing out that one is still passing a "reference" to the
object...even if it is a copy of a pointer.
AHS
|
| |
|
| |
 |
Andreas Leitgeb

|
Posted: 2008-4-7 22:48:00 |
Top |
java-programmer >> pass by reference
Lew <email***@***.com> wrote:
> Then we had really be extra careful not to spread misinformation, such as the
> canard that "call by reference" is somehow equivalent to "call by value with
> references".
I once came over to Java from C++. (and still do much in C++, even now)
I have C++-syntax in mind, like:
void foo(mystruct& r) {
if (r.field1) r.field2=42; else r.method(84);
otherfoo(r);
}
and when seeing Java source like:
class ... {
void foo(MyStruct r) {
if (r.field1) r.field2=42; else r.method(84);
otherFoo(r);
}
}
there is *some* temptation to think in C++ reference terms,
and accept reference-assignment as yet another exception to the
similarity (besides different library and other differences in
syntax), rather than as the killer evidence against my mental
model.
> Otherwise we do a huge disservice to those who wish to become
> (good) experienced programmers.
To me, this "canard" helped me quickstart into java. Only later
did I see the other mental model that explained assignment more
cleanly, but made my brain ache when I found myself losing my
grip on the algorithms for only thinking of "reference to this
and reference to that" instead of just "this and that".
Different mental models just happen, and sometimes alternative
models are not necessarily evil. Not more evil than different
human languages are, despite all the translation problems.
|
| |
|
| |
 |
Arved Sandstrom

|
Posted: 2008-4-7 22:51:00 |
Top |
java-programmer >> pass by reference
"Patricia Shanahan" <email***@***.com> wrote in message
news:ftbmf3$1bqv$email***@***.com...
> Andreas Leitgeb wrote:
>> Patricia Shanahan <email***@***.com> wrote:
>>> I came to my current position on this subject after viewing many
>>> articles reflecting parameter passing confusion, in this newsgroup and
>>> in comp.lang.java.help. I came to the conclusion that talking about pass
>>> by reference created a not unreasonable expectation of being able to
>>> change the value of a variable,
>>
>> This was, because "pass by reference" alone is indeed misleading.
>> I always wrote "passing *objects* by reference".
>
> Adding the word "objects" makes no sense at all, because there may not
> be any object. Null references can be perfectly valid actual arguments.
>
>>> What do you think is the main objective in selecting terminology to
>>> > describe Java parameter passing?
>>
>> The objective is, to explain some effect using a language that I think
>> the target knows. Natural language appears to me superior to a language
>> of technical terms with exact definitions from which only experienced
>> programmers can grasp all the subtleties.
>>
>
> Java learners can be divided, for this purpose, into two sets, those
> that already know what "pass by reference" means and those that don't.
>
> For those that don't, "pass by reference" and "pass reference by value"
> are both new language, and they might as well be told how Java really
> behaves.
>
> The issue is more critical for people for whom "pass by reference" is
> familiar language. They will think they know what it means, and have to
> find out somehow that it means something entirely different, when
> talking about Java, that it does when talking about other languages.
>
> Patricia
I certainly won't argue with any of the above. My first mainstream language
was FORTRAN, and the second was C. C++ came considerably later, and Java
much later than that. When using C (before any exposure to C++ or Java) I
and most everyone I knew used the term "pass by reference" when we were
doing "pass pointers by value", and by the very nature of what one normally
did with these pointers to the caller variables, there wasn't any confusion.
When first exposed to C++, I'll freely admit that for quite some time I
thought of references as "fixed pointers". Again, given what I did with
code, that concept never caused me problems. I knew I could change the state
of the referent inside the called code, and have that change be visible in
the calling code, and so forth.
Finally, when first exposed to Java (JDK 1.0.2) about ten years ago, I will
again freely admit that I thought of object references as "fixed pointers".
Since I normally don't write swap() functions, I don't think I for the
longest time ever really considered the difference between pass by reference
and pass pointer by value. Since in hindsight I almost always simply wanted
access inside the callee to the actual variable in the caller...something
that I did with passing pointers by value in C, either pointers by value or
references in C++, and object references by value in Java.
Pertaining to your last paragraph, I don't think it was until this same
subject (and also the "does Java have pointers?" subject) came up because of
Java, quite some years ago, that I truly consciously thought about the exact
differences. When I did understand the nuances, I can't honestly say that it
changed anything...I hadn't been running into problems with either C, C++ or
Java anyway. I don't recall that referring to "pass pointer by value" or
"pass object reference by value" as "pass by reference" ever caused me any
problems, anyhow. :-)
I don't have any problems with conceding that a more precise terminology is
best in a general discussion. It's just that a programmer who uses the term
"pass by reference" may be fully aware that they are "passing pointers by
value", and provided that he/she and his/her correspondents are on the same
sheet of music, I personally have no issue with that turn of phrase.
AHS
|
| |
|
| |
 |
ram

|
Posted: 2008-4-7 22:53:00 |
Top |
java-programmer >> pass by reference
"Arved Sandstrom" <email***@***.com> writes:
>It's simply that there are several usages of the word "reference", and you
>can't say that either is incorrect.
In Java, I deem usages correct that agree with the definitions
and usages of the Java Language Specification, Third Edition.
If they do not, I also might deem them correct if the author
has given his deviant definition.
So they line is not drawn between one usage or another usage,
but between people who are being able and willing to give a
definition and cling to it and people who are not.
If someone does use the term in a meaning different from the
meaning imposed by the Java Language Specification, Third
Edition and does not give his deviant definition - how should
one know what he intends the term to mean then, unless one is
able to read minds at distance?
|
| |
|
| |
 |
Arved Sandstrom

|
Posted: 2008-4-7 23:23:00 |
Top |
java-programmer >> pass by reference
"Andreas Leitgeb" <email***@***.com> wrote in message
news:email***@***.com...
> Patricia Shanahan <email***@***.com> wrote:
>> The issue is more critical for people for whom "pass by reference" is
>> familiar language. They will think they know what it means, and have to
>> find out somehow that it means something entirely different, when
>> talking about Java, that it does when talking about other languages.
>
> By the way, this is also true for "reference" itself. They also have
> to learn that what Java calls a reference wouldn't be called that way
> in other languages, for exactly the reasons you wrote (null allowed,
> assignment-semantics).
Hey, one's mind can get bent in new and wonderful ways. When I encountered
nullable value types in C# there's no question but that I scratched my head
a bit, particularly since before that I kept on reading statements like "a
struct instance cannot be null". Finding out that I could circumvent this
little annoyance by having nullable structs was eye-opening. :-) Admittedly
a very handy feature.
> Why is it ok, to talk of references in Java, but have an entirely
> different meaning of "reference" in mind in context of the phrase
> "pass by reference"?
Because one "reference" is an object reference, and the other means passing
the address of something, but since we're not passing the address of the
reference... :-)
> I deduced my liberty to "redefine" "pass by ref" from Java's liberty
> to redefine "reference" in the first place. My redefinition of
> it was coined on java's vocabulary: Objects are not passed directly
> (as possible in C++, where the whole structure of the object gets
> dumped on the stack), but "through use of (Java-)references".
> This is natural language as I understand it.
Natural language (computer science, but not language-specific) is that a
reference contains information referring to data stored elsewhere (the
referent). This may be accomplished with raw addresses or otherwise. AFAIK
Java and C# use handles (pointers to pointers), something quite familiar to
anyone who did lots of Macintosh programming back in the day. I stand to be
corrected if Java object references are not handles.
AHS
|
| |
|
| |
 |
Patricia Shanahan

|
Posted: 2008-4-7 23:38:00 |
Top |
java-programmer >> pass by reference
Andreas Leitgeb wrote:
...
> Because this redirects mental focus from Objects to the references,
> which I consider a less worthy goal, than you seem to do.
...
I think focus on references is key to understanding and predicting Java
behavior. There are a lot of things in Java that make perfect sense in a
reference-orientated model, but seem rather strange and arbitrary in
terms of objects.
Patricia
|
| |
|
| |
 |
Andreas Leitgeb

|
Posted: 2008-4-8 0:38:00 |
Top |
java-programmer >> pass by reference
Stefan Ram <email***@***.com> quoted James Gosling:
> In programming language design, the term pass by reference
> properly means that when an argument is passed to a
> function, the invoked function gets a reference to the
> original value, not a copy of its value.
Compilers are bright. They accept lvalues for rvalues, and
know how to retrieve the (rvalue-shaped) content from the lvalue:
int i=42, j= i +1; i=43;
in "i+1" it sees, that it uses the address only to obtain the
value, whereas in "i=43", it needs to do something completely
different with "i". (iload vs. istore or getfield vs. putfield)
People (those who follow the discussed model) are just as adaptive:
They know, when they have the variable in mind (as an lvalue),
and when they intend to identify the object with the reference.
(for the time until re-assignment of the reference)
With the mental model "Only objects are passed by ref", it's
clear, that since the variable is not an object, it will not
be "passed by ref" and changes to the variable in the callee
will not reflect back. At the same time, focussing on the
objects and treating the variables as readonly (after the
object is first assigned to them) gives exactly the effect
expected from "call by ref" - of course only on the objects.
The disadvantage of this model is, that it is incompatible
with language-police-type defenders of "the one and only
standard java-model".
The advantage is, that thinking of passing Objects (which the
other model says is impossible) saves up those all too sparse
"indirection-stack-levels" in human brain.
Anyway, I shall never again say, that "java did call by ref for
objects", but more like this: "one could see it as passing
objects by ref, as long as one avoids reference-assignments
inside the callee".
PS:
The object-oriented, rather than variable-oriented, "swap":
interface Assignable {
public Assignable createCopy();
public void assignFrom(Assignable src);
}
...
void swap(Assignable a, Assignable b) {
Assignable tmp=a.createCopy();
a.assignFrom(b); b.assignFrom(tmp);
}
...
|
| |
|
| |
 |
Andreas Leitgeb

|
Posted: 2008-4-8 1:28:00 |
Top |
java-programmer >> pass by reference
Wayne <email***@***.com> wrote:
>> 禄call by reference A call in which the calling module
>> provides to the called module the addresses of the
>> parameters to be passed.芦 (15.06.08)
If I consider my *object* to be the parameter, then passing down
a java reference pointing to my object is just "providing the called
module with the address of my object". q.e.d.
In a more abstract sense, the "address" is any type of handle by which
the object is identifyable/addressable/reachable/....
> Those who wish to claim what Java does is pass by reference, okay
> with me, just remember this is a common certification question and
> you must give the official answer when it comes up.
Fortunately one doesn't automatically fail the whole test just
for one question answered "wrongly".
> Does anyone remember Fortran's pass by copy-back (or copy-reference)?
> Or older, Algol W (I think) that used pass by name?
Tcl is another example. Basically it only supports call by value.
However such a value can be a string holding the name of a local
variable of the caller, and the callee invokes a tcl command that
links the named variable from caller scope to a callee-local variable.
set var "foo"
proc mod_by_ref {varName} { upvar $varName lcl; set lcl "bar" }
mod_by_ref var
puts $var ;# ---> prints: bar
Now, what's this? I call the procedure just with a value, namely
"var", so it's "call by value", but effectively, with help of that
"upvar" command, I get semantics of call by reference.
You won't be surprised that I had a similar discussion like this one
in comp.lang.tcl some time ago, again with people citing general
definitions of the whole "call-by-*" family (all the definitions
being not at all applicable to tcl, imho, except of course for
call-by-value, which is probably applicable in every language),
and claiming that the snippet above is anything but not "call by ref" ...
And I think it's even nearer to call-by-ref than Java, for which
call-by-ref is just a limited (but practical) model.
Above every language develops a super-language of idioms. Idioms
to mimick features not present in the base-language. Some of
these idioms are then simplified into new syntax, and the
result is C++ from C, or Java1.5 from Java-pre1.5. Many
features start as commonly used idioms. Not re-assigning
parameter references to mutable objects, or using mutable
container-objects (for otherwise immutable objects or for
primitives), is the idiom for "call-by-ref" in Java.
> I'm personally quite happy with Java's pass by copy/value only!
Fine, I'm happy with my model, too.
|
| |
|
| |
 |
Andreas Leitgeb

|
Posted: 2008-4-8 1:44:00 |
Top |
java-programmer >> pass by reference
rmoldskr+email***@***.com <rmoldskr+email***@***.com> wrote:
> Andreas Leitgeb <email***@***.com> wrote:
>> Even in C++, I'm "merely able to modify objects in a subprogram", but in C++
>> it's still called "pass by reference".
> I thought I clearly explained that in C++ you can do modify objects in a
> subprogram _both_ with pass by reference and with pass by value?
With the latter you mean "pass pointer by value"?
Yes, sure, but the example (in another sub-thread) specifically
used C++'s call-by-ref syntax, which under the hood still looks
like "pass pointer by value".
> Consider the following
> [example where pass-by-ref semantics are broken by doing a
> re-assignment - however this time on caller's side]
It's simple: do not re-assign references, and as result you
get semantics for objects that are indistinguishable from
call-by-ref. :-)
|
| |
|
| |
 |
Chris Smith

|
Posted: 2008-4-8 3:47:00 |
Top |
java-programmer >> pass by reference
Arved Sandstrom wrote:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>> concept with a well-understood definition.
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> Namely: the lvalue of the
>> formal parameter is the same as the lvalue of the actual parameter.
> [ SNIP ]
>
> Apparently not so well-understood, Chris, not if we (and tens of
> thousands, and hundreds of thousands, and millions, of others) are
> having this discussion.
Aye. I meant well-understood in the sense of it not being up for debate
or disagreement among the most knowledgeable people in the relevant
field. Sort of the way one might say (just to pick on something) that it
is well-understood that the finitely generated projective modules of a
purely infinite simple ring form a group with respect to the direct sum.
Sure, 99.999% of humanity has never heard of purely infinite simple
rings, finitely generated projective modules, or perhaps even groups.
Nevertheless, it is still well-understood.
> And the fact is, "call/pass by value/reference" is _not_ something with
> a well-understood definition, not when it comes to categorizing things
> like "pass pointer by value".
It's certainly true that a lot of people are wrong about the meaning of
these terms. But if you do your research with textbooks on programming
languages (and I don't mean Java for Dummies), and in the words of
experts, you won't find the same thing. James Gosling has already been
quoted here. More language-agnostic sources will agree.
> I myself am perfectly happy to use the more precise language to keep
> Java people happy - it's no sweat off my back.
Sure, and to be fair, in a private conversation with someone who knows
programming fairly well already, I also wouldn't interrupt anyone to
start an argument over the proper meaning of pass by reference. But in a
forum where people go to learn a programming language, in a public
discussion that is *about* the meaning of pass by reference, I'll
continue to point out the right answer.
--
Chris Smith
|
| |
|
| |
 |
Lew

|
Posted: 2008-4-8 8:36:00 |
Top |
java-programmer >> pass by reference
Arved Sandstrom wrote:
>> I myself am perfectly happy to use the more precise language to keep
>> Java people happy - it's no sweat off my back.
Chris Smith wrote:
> Sure, and to be fair, in a private conversation with someone who knows
> programming fairly well already, I also wouldn't interrupt anyone to
> start an argument over the proper meaning of pass by reference. But in a
> forum where people go to learn a programming language, in a public
> discussion that is *about* the meaning of pass by reference, I'll
> continue to point out the right answer.
Right on!
I really don't understand the apologists for imprecision. Programming
requires precision; arguing for imprecision is contrary to the commitment to
excellence in programming.
--
Lew
|
| |
|
| |
 |
Lew

|
Posted: 2008-4-8 8:40:00 |
Top |
java-programmer >> pass by reference
"Peter Duniho" wrote:
>> I really don't understand how you can, in a thread named "pass by
>> reference", think that using the imprecise form of communication makes any
>> sense whatsoever.
Arved Sandstrom wrote:
> Mainly because very early in this thread one poster very clearly said:
>
> "In java, all objects are passed by reference.
>
> Basic data types like int, long, boolean are passed by value. Object
> variables are always references to an object, and the reference is passed
> "by value" as the basic data types, but it is a reference, so..."
> Note the first sentence.
That is true. However, the fact that the post you quoted is incorrect doesn't
justify the rest of us being careless.
> You certainly can't say Java objects are passed by value either.
The reason for that is that Java objects are not passed at all.
> Point being, and I made another recent post to this effect, very many people
> do understand the distinction between pass by value and pass by reference,
> but also call "passing a pointer by value" passing by reference. You can
Which is incorrect.
> call this imprecise...me myself, if I am satisfied that the person actually
> understands that they are passing a pointer by value, and not a true
> reference, don't lose sleep if they use the term "pass by reference".
But this thread is not such a casual conversation. This thread is
specifically about the meaning of "pass by reference", therefore precision is
mandatory.
> But when talking to Java folks I'll be very careful from now on. :-)
You should extend that to all aspects of professional discipline as a
programmer, not just Java.
--
Lew
|
| |
|
| |
 |
Lew

|
Posted: 2008-4-8 8:44:00 |
Top |
java-programmer >> pass by reference
Andreas Leitgeb wrote:
> The disadvantage of this model is, that it is incompatible
> with language-police-type defenders of "the one and only
> standard java-model".
Ionteresting how you resort to name-calling when the people with whom you
disagree make an irrefutable case.
--
Lew
|
| |
|
| |
 |
Lew

|
Posted: 2008-4-8 8:53:00 |
Top |
java-programmer >> pass by reference
Andreas Leitgeb wrote:
> Patricia Shanahan <email***@***.com> wrote:
>> "pass by reference" (or more usually "call by reference") is a long
>> standing term with a meaning independent of the use of "reference" as a
>> freestanding term. I learned it long before I knew any language in which
>> one could actually have a reference.
>
> How many of the current java newbies do you think share your history
> of learning and previous knowledge?
How does that change the truth of what she says? Someone else's ignorance
cannot invalidate Patricia's knowledge.
> How many, in contrast, come from C++, and see the syntactical
> similarity (except for assignment) between Java's way of passing
> around references to Objects and C++'s way of passing objects
> (among other stuff) by reference?
They may be similar, but they aren't the same. You really are an apologist
for imprecision here.
>> I don't see any reason why having to learn a Java-specific meaning
>> of reference should require people to learn special meanings of other
>> terms,
>
> Because a substantial part of them doesn't know that general overall
> meaning of "pass by ref", and thus take it literally and thusly
> automatically in context with the "references" at hand in java.
And people who don't know the meaning of "assignment", they don't need to
learn the correct definition of that to be programmers either?
Programming is a *learned* art. You have to learn it. That means learning
the definitions of the terms - the *correct* definitions. Not having learned
it before is not a reason to refuse to learn it now. I should think that any
responsible programmer would be thrilled to learn the correct, precise
terminologies, instead of straining a muscle trying to argue against them.
> An archaic definition of the phrase without also a definition for
> the terms used in both the phrase and its definition, isn't all
> that shiny nowadays. Perhaps just like a green on black 80x24
> vt100 doesn't have the same exciting flair to everyone.
Now by calling a venerable term "archaic" do we hope to invalidate the correct
definition?
>> especially when with have a perfectly good phrase,
>> "pass reference by value", that is only one word
>> longer and says *exactly* how Java behaves.
>
> Because this redirects mental focus from Objects [sic] to the references,
> which I consider a less worthy goal, than you seem to do.
But that is the correct focus! It isn't about "considering it worthy" but
about accurately and precisely describing what's happening. When you pass a
parameter to a Java method, whatever your personal "mental focus" is will not
affect the reality of what is happening, which is that a method argument is
*never* an object in Java. If you are "mentally focusing" on objects as
method arguments, then you have misunderstood what is happening. It would
behoove you to shift your "mental focus" to the reality, however unworthy it
may be.
Again, simply applying pejoratives to the truth will not make it less true.
--
Lew
|
| |
|
| |
 |
Andreas Leitgeb

|
Posted: 2008-4-8 14:30:00 |
Top |
java-programmer >> pass by reference
Stefan Ram <email***@***.com> wrote:
> If someone does use the term in a meaning different from the
> meaning imposed by the Java Language Specification, Third
> Edition and does not give his deviant definition - how should
> one know what he intends the term to mean then, unless one is
> able to read minds at distance?
I submit this one:
" 禄call by reference A call in which the calling module
" provides to the called module the addresses of the
" parameters to be passed.芦 (15.06.08)
I think we agree on these terms, but disagree on the definition
of the words used. Especially the "parameter" - you take it as
only the very lvalue that is literally written, but I take it more
abstractly as whatever chunk of information I want the called
module to deal with and possibly modify.
My interpretation of a "parameter" would even include the contents
of a file on disk, whose filename(the "address") I pass to the module
as a string.
In a language neutral definition of "call by reference", I just can't
see how picking a very concrete low-level definition of the
words "parameter" and "address" can be claimed to be the only one
reasonable.
|
| |
|
| |
 |
Lew

|
Posted: 2008-4-8 19:17:00 |
Top |
java-programmer >> pass by reference
Andreas Leitgeb wrote:
> In a language neutral definition of "call by reference", I just can't
> see how picking a very concrete low-level definition of the
> words "parameter" and "address" can be claimed to be the only one
> reasonable.
This is especially true of Java, where the low-level details of addresses can
vary in the face of HotSpot optimizations.
--
Lew
|
| |
|
| |
 |
| |
 |
Index ‹ java-programmer |
- Next
- 1
- serialVersionUID.. ?Hello ,
I posted this message in the Eclpse group with no responses. I am using
Eclipse.
I resolved by defining this in my class:
static final long serialVersionUID = 0;
Now, all of a sudden, this is not working and getting error:
Syntax error on token "DETAIL_FOOTER", VariableDeclaratorId expected after
this token
Happens when I define this class var in applet or interface:
private DETAIL_FOOTER = "# detail footer";
I do not have a clue! Any one have any Ideas?
--
Thanks in Advance...
IchBin
_____________________________________________
'Black holes are where God divided by zero.'
-Steven Wright, comedian (1955- )
- 2
- Java Timer, swingDear Java experts,
I'm struggling with timers. I've used javax.swing.Timer in my program. But
when one doesn't have the jre installed, my program doesn't work. It then
gives a class not found exception in the browser. It only works on the sun
virtual machines which you have to download from the website like some jre.
I quess the swing library isn't supported by a lot of virtual machines. But
I'm happy about how the timer works in my program because it makes use of
the actionListener.
Is there some easy solution? Using a simple Timer like the swing version and
let it work on any virtual machine/ jre?
best regards,
Piet den Dulk (Netherlands)
- 3
- how to hide tabs in JTabbedTableHello all
I have a JTabbedTable with many tabs with JPanel in it. I want in a state,
only some tabs are shown and other states, other tabs are shown. I used
setVisible(boolean) but it does not work. could you please help
thank you
S.Hoa
- 4
- You have received 5 notifications from your fans!Alyssa
<http://www.fanbox.com/socnet/EmailStat.aspx?cmp=&xyz=1&lit=5&me=xAr3pqu
jU0kBSGmCF6dKsg==&fan=F1Qw1zM6IEk=&opg=http://profile.fanbox.com/profile
/NewCustomProfile.aspx?u=alyssawilcox591> sent you a fan request.
Automatically sign in
<http://www.fanbox.com/socnet/EmailStat.aspx?cmp=&xyz=1&lit=5&me=xAr3pqu
jU0kBSGmCF6dKsg==&fan=F1Qw1zM6IEk=&opg=http://profile.fanbox.com/Inbox/M
ain.aspx?messages=3> to view Alyssa's profile and to accept or reject
her fan request.24 hours ago
Alyssa
<http://www.fanbox.com/socnet/EmailStat.aspx?cmp=&xyz=1&lit=5&me=xAr3pqu
jU0kBSGmCF6dKsg==&fan=F1Qw1zM6IEk=&opg=http://profile.fanbox.com/profile
/NewCustomProfile.aspx?u=alyssawilcox591> sent you a fan request.
Automatically sign in
<http://www.fanbox.com/socnet/EmailStat.aspx?cmp=&xyz=1&lit=5&me=xAr3pqu
jU0kBSGmCF6dKsg==&fan=F1Qw1zM6IEk=&opg=http://profile.fanbox.com/Inbox/M
ain.aspx?messages=3> to view Alyssa's profile and to accept or reject
her fan request. 24 hours ago
Alyssa
<http://www.fanbox.com/socnet/EmailStat.aspx?cmp=&xyz=1&lit=5&me=xAr3pqu
jU0kBSGmCF6dKsg==&fan=F1Qw1zM6IEk=&opg=http://profile.fanbox.com/profile
/NewCustomProfile.aspx?u=alyssawilcox591> sent you a fan request.
Automatically sign in
<http://www.fanbox.com/socnet/EmailStat.aspx?cmp=&xyz=1&lit=5&me=xAr3pqu
jU0kBSGmCF6dKsg==&fan=F1Qw1zM6IEk=&opg=http://profile.fanbox.com/Inbox/M
ain.aspx?messages=3> to view Alyssa's profile and to accept or reject
her fan request. 24 hours ago
There are 2 additional fan requests to review
<http://www.fanbox.com/socnet/EmailStat.aspx?cmp=&xyz=1&lit=5&me=xAr3pqu
jU0kBSGmCF6dKsg==&fan=F1Qw1zM6IEk=&opg=http://profile.fanbox.com/Inbox/M
ain.aspx?messages=3> .
Click here to view ALL notifications
<http://www.fanbox.com/socnet/EmailStat.aspx?cmp=&xyz=1&lit=5&me=xAr3pqu
jU0kBSGmCF6dKsg==&fan=F1Qw1zM6IEk=&opg=http://profile.fanbox.com/Inbox/M
ain.aspx?messages=> Change your Email Summary Settings
<http://www.fanbox.com/socnet/EmailStat.aspx?cmp=&xyz=4&lit=5&me=xAr3pqu
jU0kBSGmCF6dKsg==&fan=F1Qw1zM6IEk=&opg=http://profile.fanbox.com/Prefere
nces/Main.aspx?open=emailPref>
You can control
<http://www.fanbox.com/socnet/EmailStat.aspx?cmp=&xyz=4&lit=5&me=xAr3pqu
jU0kBSGmCF6dKsg==&fan=F1Qw1zM6IEk=&opg=http://profile.fanbox.com/Prefere
nces/Main.aspx?open=emailPref> the frequency of these summary emails.
FanBox - 255 G Street #723, San Diego, CA 92101, USA
- 5
- "Linked List" AssistanceCan someone please point me to a url that will show me how to create a
linked list.
This needs to be a very simple example as Linked Lists are confusing me.
Thankyou for your assistance.
- 6
- Image from WebHi all, I need to read an image located in http://www.xxx.yyy/eee/test.jpg
...how can I do?
How can I display once readed in a swing interface?
thanks.
mario
- 7
- the MI 5 spammeremail***@***.com wrote:
> Incorrect. None of the nasty things that you have said or implied
> about me are at all true.
Does this mean you still accuse me of hacking OpenOffice.org's mailing
lists? What a hoot!
- 8
- JNI CallStaticVoidMethod fails after N callsI have written an application in Java and C on the Solaris 10 (x86)
platform using the JDK 1.5.0_09. The Java code calls a native method
"startButtonWatcher," which then forks, the parent process returning,
and the child process initiating an event loop that calls a static
method, "sendButtonEvent," on a Java class "ButtonWatcher."
The problem is that on the 65 invocation, the CallStaticVoidMethod will
hang. There is no core file or pid log file produced. (it will also
hang for CallVoidMethod as well if I remove the static declaration in
ButtonWatcher.)
I have also added a main() function to the C code so that it can be
compiled and run as an executable rather than a library file loaded
from Java, and the the same loop will be fine, the Call*Method call
being exected forever (or over a million times at least). The only
difference in the code is the JVM--in the sharable library, it uses the
JVM of the class that calls the native method, and the standalone has
to create its own. What could be the problem? Thanks!
- 9
- 10
- Problem running the hello world servletI installed j2sdk1.4.2_12, and apache tomcat 4.1.34, on a windows XP
box. I set the following environment variables:
CATALINA_HOME C:\apache-tomcat-4.1.34
CLASSPATH C:/Program
Files/Java/jre1.5.0/lib/xt/QTJava.zip;C:/j2sdkee1.3.1/lib
J2EE_HOME C:/j2sdkee1.3.1
JAVA_HOME C:/j2sdk1.4.2_12
PATH C:\j2sdk1.4.2_12\bin\
I edited the web.xml in C:\apache-tomcat-4.1.34\conf and uncommented
the invoker servlet tag so that I can run servlets.
I can now access jsp and html pages with tomcat, but when I tried to
run HelloWorld Servlet, it gives the following error:
ava.util.MissingResourceException: Can't find bundle for base name
LocalStrings, locale en_US
at
java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:838)
at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:807)
at java.util.ResourceBundle.getBundle(ResourceBundle.java:578)
at HelloWorldExample.doGet(HelloWorldExample.java:38)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:696)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
at
org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:417)
at
org.apache.catalina.servlets.InvokerServlet.doGet(InvokerServlet.java:131)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:696)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:198)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:144)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:209)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:595)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:432)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:954)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:138)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:595)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:432)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:954)
at
org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2459)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:132)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:595)
at
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:118)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:593)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:116)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:593)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:432)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:954)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:126)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:595)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:432)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:954)
at
org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:152)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:534)
What could be the problem?
- 11
- Creating an object during runtimeI'm trying to generate an object name during run time, and then create an
object with the contents of that variable. You can see that I'm trying to
also make the object name self generating (almost, the 'y' variable isnt
being incremented yet), putting two values ('y' and 'C'). My apologies for
poor coding structure / lack of comments, but I'm am a bit lost on how to
work it out. MANY thanks in advance.Heres what I have so far:
public class testVariable
{
private String name = "";
private String New_name = "";
private int y = 2;
public testVariable()
{}
public void test(String x)
{
name = x;
New_name = name + y ;
System.out.println(New_name);
}
public String getNew_name()
{
return New_name;
}
public static void main(String[] args)
{
int z = 2;
testVariable Darren = new testVariable();
Darren.test("C");
testVariable "c"+ z = new testVariable();
String Old_name = New_name;
}
}
- 12
- How to make sure stdout and stderr is caught from runtimeexecHi,
I have written a class that handles stdout and std err from a unix
command. How can I make sure that both threads have finished? Do I need
to synchronzie my StreamConverter?
cheers,
//mikael
> public class RuntimeExec {
>
> public RuntimeExec() {
> }
>
> /**
> * Executes a command
> * @param command
> * @return The result of the command
> * @throws IOException
> */
> public String exec(String command) throws IOException {
> int exitValue = 0;//0 - executed ok.
> String stdOut = null;
> String stdErr = null;
> String result = null;//result from clearcase operation
> StringBuffer out = new StringBuffer();
> StringBuffer err = new StringBuffer();
> Process process = Runtime.getRuntime().exec(command);
> StreamConverter outSc = new StreamConverter(process.getInputStream(),out);
> StreamConverter errSc = new StreamConverter(process.getErrorStream(),err);
> Thread outThread = new Thread(outSc);
> Thread errThread = new Thread(errSc);
> outThread.start();
> errThread.start();
> //Wait until the prosess finish
>
> long delayMillis = 5000; // 5 seconds
> try {
> //wait for threads to die.
> outThread.join(delayMillis);
> if (outThread.isAlive()) {
> // Timeout occurred; thread has not finished
> } else {
> // Finished
> }
> } catch (InterruptedException e) {
> // Thread was interrupted
> }
>
>
>
>
> return result;
>
>
> }
>
> // bridge between byte and character stream.
> class StreamConverter implements Runnable {
> private InputStreamReader isr = null;
> private StringBuffer sb = null;
> // end of steam
> private static final int EOS = -1;
>
> public StreamConverter(InputStream is, StringBuffer sb) {
> isr = new InputStreamReader(is);
> this.sb = sb;
> }
>
> public void run() {
> int character = 0;
> try{
> while ((character = isr.read()) != EOS) {
> sb.append((char)character);
> }
> }catch(IOException ioe){
> System.out.println("Could not read std out!"+ioe.getMessage());
> }
> }
>
> }
>
>
> }
- 13
- url rewriting when the url contains parametersHi,
I am trying to maintain sessions by doing URL rewrite. Things were
working fine till the URL did not contain any parameters. The URL that
I have now is of the form:
http://myurl?id=1&user=null and on doing a sessionID append it becomes
http://myurl?id=1&user=null;jsessionId=xyzw..
Things still get authenticated but now when I try and get the value of
user I get passed the whole string after user= and not just null.
What is the right way to append the sessionID? Btw, I am using the URL
to connect to a servlet from a j2me client.
Thanks,
Gaurav
- 14
- Intellij 5.1 compile time error..hi,
I am using Intellij 5.1 version. Each time I build the project I get
an error:
error: Compiling Web Module 'web':Invalid file
and the file is in the "deploy" folder
So each time I go into the folder and maually delete the .war file and
then when I build the project it works fine.
>From what I have seen one more person using the same version has this
problem. but the one's using the earlier versions don't have this
problem.
Is there any solution for this?
thanks,
- 15
- Please can you help me how can apply unicode in javaI am tr y to develope a localization application.when i run the code
there is no the right output, it's square box but i can't fix the error
and why it's like that .but i know the unicode representation of my
language please look a sample of code and based on that give me
suggestion to fix the erro.
import java.io.*;
class Unicodechar{
public static void main(String[] args){
//declare a character initialized to Ethiopic
char fidel='\u1200';
// print Ethiopic Unicode (version 3.0)
while(fidel<='\u137C'){
for(int i=0;i<8;i++){
System.out.println((int)fidel +", ");
fidel++;
}
//System.out.println();
}
}
}
|
|
|