| crash during file writing, how to recover ? |
|
 |
Index ‹ java-programmer
|
- Previous
- 1
- Execute JSP within a servlet ?Hi folks,
A bug in cocoon prevents me from using it with JSP ... so I decided to
do my own implementation. I want to load up and execute a JSP file from
within a servlet, and from the generated XML doc apply an XSL style
sheet, then send back HTML to the browser. This is doable right ? since
a jsp doc somehow gets compiled and executed within a servlet anyway
... Is there an example of how this can be done ?
Also, am I going to miss out on some possible caching that happens
magically when I invoke a jsp directly from the browser ?
Many thanks,
galpi
- 1
- Set Txd always UPHello,
I use Java Comm, and i would like to know if i can use Txd (or td)
like RTS or DTR with Java Comm and how could I do this?
sample setTxd( true) and Txd=12v
setTxd( false) and Txd=-12v
- 1
- Interfaces vs. Abstract.Greetings,
I have googled around a bit about this one and consulted my various Java
tomes on the differences between abstract classes and interfaces.
They seem to be similar ideas *_BUT_* interfaces have no method code (i.e.
only abstract methods), just signatures and final static identifiers.
Abstract classes can have method code as well a abstract methods, constants
and non-constants.
It is possible for a class to implement multiple interfaces (in C++ talk
inherit from multiple abstract base classes) but a class can only extend
one other class (again in C++ese inherit from one class).
Is this understanding correct?
What general guidelines do you use to determine when to use an interface vs.
abstract classes?
For example I am working on creating a ReportWriter. I want the ReportWriter
to be able to write out in PostScript, text, and in HTML. I am thinking
about using an interface.
All three need to create headers, footers, and write detail lines. However,
the details of each operation are completely different from the other.
Thanks
--
From: Mark A Framness <email***@***.com>
http: http://netnet.net/~farmer/index.html
With all of thy getting, get understanding!
Proverbs 4:7
- 5
- Java ArchitectDoes this forum have an experienced Java Architect? I would like to
bounce a few questions to someone with some industry experience. I am
the project manager for a new software app. I would like some advice on
java architecture and technologies. Appreciate this is all high-level,
but if certain technologies jump out to you then please let me know.
Scenario: Message brokering of news items over a LAN
User view is a java applet or could be java enabled web page (some kind
of smart console running on their PC desktop)
For now the application will have 50 users all on the same internal
network.
Central Oracle/SQL Server Repository - holding messages.
All clients communicate with central database that holds messages and
configuration information.
Based on the config. found each java client will dynamically build drag
and drop lists/trees of this information.
Ability to screen capture based on a user selection and upload the
image to a DB repository
Each client will be able to post new messages to the server which will
need to alert the other clients.
An author of a message can see if messages have been read by the
consumers. If the user has not read the author can send a warning to
that particular user.
Licensing needs to be built in to restrict to 50 concurrent users.
Security login screens are required. Use central db server to
authenticate.
Scenario2: This is where it gets interesting. How would this change in
a WAN scenario? - Could this even work using zero front print java?
Also if you live in/near London then please let me know.
Andy
- 5
- Modify image and save to fileI want to read a .png image from a file, replace a color with a new color,
and write it back to a .png file.
I've managed to read the file into a BufferedImage. I've got a PixelGrabber
to look at the pixels, identify those of the old color, and replace them
with the new color, leaving me with an int[] of the pixels I want.
How do I modify write the modified pixels out to a .png file? I don't care
if I overwrite the original image or write to a new one.
No matter how I try to do it I end up with a new file that is identical to
the original, even though I can tell my code is correctly identifying the
pixels I want to change.
Please help,
Tim
- 6
- Just upgraded to the newest jdk 1.5I just upgraded my jdk 1.5 to the newest version in ports after I saw a
commit fixing a performance issue.
My swing application now behaves very well without being sluggish at all
and looks much nicer than with jdk 1.4.
Thank you very much for your great work on this.
--
Christian Laursen
- 6
- Brand Watches Fila Men's Matrice watch #FLA55302 Discount, Replica, FakeBrand Watches Fila Men's Matrice watch #FLA55302 Discount, Replica,
Fake
Browse our Fila Men's Matrice watch #FLA55302 replica watches, which
is sure the watch you are looking for at low price. There are more
high quality designer watch replicas for selection
Fila Men's Matrice watch #FLA55302 Link : http://www.watches-brand.com/Replica-Fila-8343.html
Brand : Fila ( http://www.watches-brand.com/Fila-Replica.html )
Model : Fila Men's Matrice watch #FLA55302
Description :
<p>Digital quartz movement, Sport watch, Regular timekeeping, 100 laps
memory, World time function, 8 schedules reminder, Chronograph 1/100,
Second - Alarm, Black polycarbonate case, Lime green polyurethane
selector buttons, Black polycarbonate case, Stainless steel caseback,
50 meters/165 feet water resistant</p>
Sale Price : $ 210.00
Fila Men's Matrice watch #FLA55302 Details :
<ul>
<li>Brand: Fila</li>
<li>Dial color: Black polycarbonate case, Digital dial (253 dot m</li>
</ul>
Fila Men's Matrice watch #FLA55302 is new brand replica, join
thousands of satisfied customers and buy your Fila with total
satisfaction. A watches-brand.COM 30 Day Money Back Guarantee is
included with every Fila Replica Series for secure, risk-free online
shopping. watches-brand.COM does not charge sales tax for the Fake
Fila Men's Matrice watch #FLA55302.
All of our replica watches are shipped via EMS to worldwide. Normally
it takes 3days to prepare the fake watch you ordered and 5-10days to
transmit depending on the different destination.We pay for the free
shipping cost for total quantity over 20 pcs. The EMS tracking NO.
will be sent by email when an order is shipped from our warehouse. No
more other charges from watches-brand.com such as the tax. If you have
any other questions please check our other pages or feel free to email
us by email***@***.com.
The Same Replica Fila Watches Series :
Fila Men's Metropolis watch #21204 :
http://www.watches-brand.com/Replica-Fila-8344.html
Fila Women's Metropolis watch #21206 :
http://www.watches-brand.com/Replica-Fila-8345.html
Fila Men's Polaris watch #FLA63273 :
http://www.watches-brand.com/Replica-Fila-8346.html
Fila Men's Polaris watch #FLA63298 :
http://www.watches-brand.com/Replica-Fila-8347.html
Fila Women's Posh watch #31407 :
http://www.watches-brand.com/Replica-Fila-8348.html
Fila Men's Proteon watch #21803 :
http://www.watches-brand.com/Replica-Fila-8349.html
Fila Men's Proteon watch #21813 :
http://www.watches-brand.com/Replica-Fila-8350.html
Fila Men's Synthesis watch #31304 :
http://www.watches-brand.com/Replica-Fila-8351.html
Fila Men's Synthesis watch #31308 :
http://www.watches-brand.com/Replica-Fila-8352.html
Fila Women's The Bits watch #21601 :
http://www.watches-brand.com/Replica-Fila-8353.html
Brand Watches Fila Men's Matrice watch #FLA55302 Discount, Replica,
Fake
- 7
- Quick questionI am not sure if this is the group i should post this question so
maybe you can point me in the right direction.
I have a computer and when I install the java runtime environment it
installs but when i try to access a page that uses java the screen
freezes and some times turnes scrambles with blue colors. I have
never seen anything like this. The OS works fine otherwise. I have
tryed to uninstall and reinstall. The web site I go to needs it and
if you don't have it installed it begins an installation for you.
Thanks for any help you can give me
Ben Dunning
- 9
- Screen Fonts in SwingHello everybody;
Is there a way to access screen fonts (Fixedsys, Courier, Terminal ...)
on a windows machine using java swing. I tried the following. . .
GriphicsEnvironment.getAvailableFontFamilyNames()
but it does not return screen font names. I also tried
Font fn=new Font("Courier",Font.PLAIN,10)
But it returns 'Courier New' font instead of 'Courier'.
- 12
- comp.lang.java.{help,programmer} - what they're for (mini-FAQ 2004-10-08)Last-Modified: Fri Oct 8 11:38:42 2004 by David Alex Lamb
Archive-name: computer-lang/java/help/minifaq
Posting-Frequency: every 4 days
Before posting read Jon Skeet's "How to get answers on the comp.lang.java.*
newsgroups" at http://www.pobox.com/~skeet/java/newsgroups.html
Java FAQs and advice:
- Java FAQ (Andrew Thompson) http://www.physci.org/codes/javafaq.jsp
including his list of other FAQs http://www.physci.org/codes/javafaq.jsp#faq
- Java/Javascript/Powerbuilder HOWTO (Real Gagnon)
http://www.rgagnon.com/howto.html
- Java Glossary (Roedy Green) http://www.mindprod.com/jgloss.html
- jGuru jFAQs (John Zukowski) http://www.jguru.com/jguru/faq/
- Focus on Java (John Zukowski) http://java.about.com/
- Java Q&A (David Reilly) http://www.davidreilly.com/jcb/faq/
- Java GUI FAQ (Thomas Weidenfeller) http://www.physci.org/guifaq.jsp
comp.lang.java.help Set-up problems, catch-all first aid.
According to its charter, this unmoderated group is for immediate help
on any Java problem, especially when the source of the difficulty is
hard to pin down in terms of topics treated on other groups.
This is the appropriate group for end-users, programmers and
administrators who are having difficulty installing a system capable of
running Java applets or programs. It is also the right group for
people trying to check their understanding of something in the
language, or to troubleshoot something simple.
comp.lang.java.programmer Programming in the Java language.
An unmoderated group for discussion of Java as a programming language.
Specific example topics may include:
o types, classes, interfaces, and other language concepts
o the syntax and grammar of Java
o threaded programming in Java - sychronisation, monitors, etc.
o possible language extensions (as opposed to API extensions).
The original charter said that discussion explicitly should not include
API features that are not built into the Java language and gave examples
like networking and the AWT. These days AWT belongs in clj.gui, and
networking (and many other APIs) are often discussed in clj.programmer.
Do not post binary classfiles or long source listings on any of these
groups. Instead, the post should reference a WWW or FTP site (short source
snippets to demonstrate a particular point or problem are fine). For some
problems you might consider posting a SSCCE (Short, Self Contained, Correct
(Compilable), Example); see http://www.physci.org/codes/sscce.jsp
Don't post on topics that have their own groups, such as:
comp.lang.java.3d The Java 3D API
comp.lang.java.advocacy Arguments about X versus Y, for various Java X and Y
comp.lang.java.beans JavaBeans and similar component frameworks
comp.lang.java.corba Common Object Request Broker Architecture and Java
comp.lang.java.databases Using databases from Java
comp.lang.java.gui Java graphical user interface design and construction
comp.lang.java.machine Java virtual machines, like JVM and KVM
comp.lang.java.security Using Java securely
comp.lang.java.softwaretools Tools for developing/maintaining Java programs
Don't cross-post between these groups and c.l.j.programmer or .help -- it just
wastes the time of people reading the general groups.
Don't post about JavaScript; it's a different language. See
comp.lang.javascript instead.
--
"Yo' ideas need to be thinked befo' they are say'd" - Ian Lamb, age 3.5
http://www.cs.queensu.ca/~dalamb/ qucis->cs to reply (it's a long story...)
- 12
- Data entry applicationHi,
I am an intermediate computer science student and I am in need of a "macro
type" tool/language that will let me automate a data entry process. The
data entry is rather simple but requires connecting to a server in between
data inputs, which ends up taking a lot of time per entry (about 10 minutes
per complete entry). On average, there are 50 - 100 entries to be made (10
min * 50 entries = one hell of a boring day.) The data that is to be
entered is in Excel, and then I (or some other unlucky person) must enter
the data manually into a prompt/DOS-like program run in the Windows (2000)
environment.
Would you know of anything that could help? Is there a way to do something
like this with any language? What would be required to setup the automation
(in the Windows environment)? I am pondering if a simple Windows
application that replicates key-strokes and has a timer capability would do
the trick (although I doubt it would be able to read the spreadsheets)?
Please let me know if you have any suggestions or comments. My thanks in
advance for any help.
email***@***.com
- 13
- native jdk release schedule questionHi folks,
I am trying to find any information regarding the release schedules of
native java1.4 in binary form. As far as I understand the license allows for
a binary distribution. On the freebsd site latest news regarding java is
from December 2003. How do things look like? Or my question makes no sense
at all?
Cheers, Dani
_______________________________________________
email***@***.com mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-java
To unsubscribe, send any mail to "email***@***.com"
- 13
- Eclipse IDE Javadoc TooltipsHi:
I'm using the Eclipse IDE for Java development, but am running into
some problems with the "Content\Code Assist" feature. Normally, when I
partially enter the name of a particular class of package, the IDE
automatically displays possible completions based on that string of
text. However, the IDE is also supposed to show me the associated
Javadoc for that class.
I know that this feature is enabled because it is able to show me the
associated Javadocs for any classes that I write myself and reside in
the current project.
I have set the Javadoc location for that project to the following
directory (gotten after unzipping the documentation download file):
file:/E:/Java API/docs/api/
However, it does not show any Javadocs for the other classes that are
in the Java API.
Can anyone help out?
Thanks,
- ADH
- 13
- load JNI from resource file?I am able to write a C native interface and load it using the
System.loadLibrary() routine.
Is there anyway to store the native interface library (say
"hello.dll") into a jar and then load the file from the jar?
- 16
- question about DES APIHello All,
The following is the code I wrote to do DES encryption.
public byte[] run ()throws Exception
{
// TODO Auto-generated method stub
byte[] re = null;
byte[]re1 = null;
if (key.length != 8){
throw new DesException("Invalid Key!!!");
}
KeyGenerator kg = KeyGenerator.getInstance("DES");
SecretKey sk = kg.generateKey();
SecretKeySpec desKey = new SecretKeySpec(key, "DES");
Cipher des = Cipher.getInstance("DES");
if ((comm == Cipher.DECRYPT_MODE) && (data.length != 8)){
throw new DesException("Invalid Key!!!");
}
des.init(Cipher.ENCRYPT_MODE, desKey);
int l = des.getOutputSize(8);
re = des.doFinal(data);
des.init(Cipher.DECRYPT_MODE, desKey);
l = des.getOutputSize(16);
re1 = des.doFinal(re);
return re;
}
I don't understand why I try entrypt 8 bytes data, the the length of
return value is 16 bytes, the first 8 bytes are what I want, what are
last 8 bytes? as far as I know, for des, the input block is 8 bytes,
output block is 8 bytes too. I use this return value to decrypt, I got
correct value.
If I just input first 8bytes to decrypt I got exception.
Anyone can explain this to me or recommend any detail document about
these API?
Thanks a lot.
|
| Author |
Message |
Joseph

|
Posted: 2004-4-30 9:37:00 |
Top |
java-programmer, crash during file writing, how to recover ?
Hi
I'm writing a commercial program which must be reliable. It has to do
some basic reading and writing to and from files on the hard disk,
and also to a floppy.
I have foreseen a potential problem. The program may crash
unexpectedly while writing to the file. If so, my program should
detect this during startup, and then (during startup) probably delete the
data added to the file and redo the writing operation.
Are file writing operations atomic ? ie when you write to a file,
will it either do it succesfully, OR say half fail (eg write a few letters
and not finish), OR not commit any changes to the file if a crash at
this point occurs?
My next question is how is this handled in commercial programming? I
plan on writing a flag (say, a simple char) to another file (this
would signal that a file write is about to begin), and then
removing this char after the file writing operation is completed.
Then on startup i just check the flags. if flag hasn't been removed a
crash occurred, so have to open file and get rid of any garbage.
Has anyone done anything similar b4? if so how did you handle this
crash scenario. My application could totally stuff up if i don't
handle this right.
by the way, i'm using the java language and api. this might effect
how files are written to, so i thought i should mention this.
MANY THANKS
Joseph
|
| |
|
| |
 |
Liz

|
Posted: 2004-4-30 11:25:00 |
Top |
java-programmer >> crash during file writing, how to recover ?
"Roedy Green" <email***@***.com> wrote in message
news:email***@***.com...
> On Fri, 30 Apr 2004 01:36:56 GMT, Joseph <email***@***.com> wrote or
> quoted :
>
> >Are file writing operations atomic ? ie when you write to a file,
> >will it either do it succesfully, OR say half fail (eg write a few
letters
> >and not finish), OR not commit any changes to the file if a crash at
> >this point occurs?
>
> Imagine a floppy being written. The power fails half way through
> writing one of your tracks. You then have gibberish on your floppy.
> Further the fat and directory are likely out of sync. When you use
> CHKDSK /F it tries to fix this. The file contains gibberish. You
> probably should bulk erase and reformat such a floppy.
>
> A very easy way to detect the problem is to write small file before
> you start. You do your thing, and on exit you erase the file. You
> can do this to any app by doing the creating testing and deleting in
> bat language.
>
> When you start, you check for the presence of the file. If you see it
> you assume the worst, and demand a restore from backup or whatever you
> need to do to get going again safely.
>
>
> --
> Canadian Mind Products, Roedy Green.
> Coaching, problem solving, economical contract programming.
> See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
I had an interesting situation a few years ago. I was using stacker
on my hard disk since it was only 20 megabytes. And I happened to
be doing a squeeze type operation when my battery died. At the next
powerup, stacker gave a message on the screen that it discovered that
it crashed during a squeeze and proceeded to automatically clean up.
I was impressed.
|
| |
|
| |
 |
Calum

|
Posted: 2004-4-30 18:49:00 |
Top |
java-programmer >> crash during file writing, how to recover ?
Joseph wrote:
> Hi
> I'm writing a commercial program which must be reliable. It has to do
> some basic reading and writing to and from files on the hard disk,
> and also to a floppy.
>
>
> I have foreseen a potential problem. The program may crash
> unexpectedly while writing to the file. If so, my program should
> detect this during startup, and then (during startup) probably delete the
> data added to the file and redo the writing operation.
>
> Are file writing operations atomic ? ie when you write to a file,
> will it either do it succesfully, OR say half fail (eg write a few letters
> and not finish), OR not commit any changes to the file if a crash at
> this point occurs?
>
> My next question is how is this handled in commercial programming? I
> plan on writing a flag (say, a simple char) to another file (this
> would signal that a file write is about to begin), and then
> removing this char after the file writing operation is completed.
> Then on startup i just check the flags. if flag hasn't been removed a
> crash occurred, so have to open file and get rid of any garbage.
>
> Has anyone done anything similar b4? if so how did you handle this
> crash scenario. My application could totally stuff up if i don't
> handle this right.
>
> by the way, i'm using the java language and api. this might effect
> how files are written to, so i thought i should mention this.
One approach is to write to a temporary file, then when writing has
completed successfully, and the file has been closed, rename the
temporary file to the target filename. That way you won't run out of
disk space either. If you need to overwrite an old file, delete it just
before renaming. If your program crashes during temporary file
creation, you'll be left with a damaged temp file that is never used
again - no big deal.
Calum
|
| |
|
| |
 |
Norm Dresner

|
Posted: 2004-4-30 23:37:00 |
Top |
java-programmer >> crash during file writing, how to recover ?
Always write to a new file and then delete the old one and rename the new.
Also, consider writing a journal file before writing to the new file so you
can at least "recover" what's missing.
Norm,
"Joseph" <email***@***.com> wrote in message
news:Y4ikc.4363$email***@***.com...
> Hi
> I'm writing a commercial program which must be reliable. It has to do
> some basic reading and writing to and from files on the hard disk,
> and also to a floppy.
>
>
> I have foreseen a potential problem. The program may crash
> unexpectedly while writing to the file. If so, my program should
> detect this during startup, and then (during startup) probably delete the
> data added to the file and redo the writing operation.
>
> Are file writing operations atomic ? ie when you write to a file,
> will it either do it succesfully, OR say half fail (eg write a few letters
> and not finish), OR not commit any changes to the file if a crash at
> this point occurs?
>
> My next question is how is this handled in commercial programming? I
> plan on writing a flag (say, a simple char) to another file (this
> would signal that a file write is about to begin), and then
> removing this char after the file writing operation is completed.
> Then on startup i just check the flags. if flag hasn't been removed a
> crash occurred, so have to open file and get rid of any garbage.
>
> Has anyone done anything similar b4? if so how did you handle this
> crash scenario. My application could totally stuff up if i don't
> handle this right.
>
> by the way, i'm using the java language and api. this might effect
> how files are written to, so i thought i should mention this.
>
>
> MANY THANKS
> Joseph
>
>
>
|
| |
|
| |
 |
Kasper Dupont

|
Posted: 2004-5-1 0:25:00 |
Top |
java-programmer >> crash during file writing, how to recover ?
Norm Dresner wrote:
>
> Always write to a new file and then delete the old one and rename the new.
No need to delete the old one first. Renaming will
automatically delete the old file.
--
Kasper Dupont -- der bruger for meget tid paa usenet.
For sending spam use email***@***.com and email***@***.com
/* Would you like fries with that? */
|
| |
|
| |
 |
Nate Smith

|
Posted: 2004-5-1 1:05:00 |
Top |
java-programmer >> crash during file writing, how to recover ?
Kasper Dupont wrote:
> Norm Dresner wrote:
>
>>Always write to a new file and then delete the old one and rename the new.
>
>
> No need to delete the old one first. Renaming will
> automatically delete the old file.
>
often that will lead to a "cant rename, file already exists"
sort of error....
- nate
|
| |
|
| |
 |
Kasper Dupont

|
Posted: 2004-5-1 1:59:00 |
Top |
java-programmer >> crash during file writing, how to recover ?
Nate Smith wrote:
>
> Kasper Dupont wrote:
>
> > Norm Dresner wrote:
> >
> >>Always write to a new file and then delete the old one and rename the new.
> >
> >
> > No need to delete the old one first. Renaming will
> > automatically delete the old file.
> >
>
> often that will lead to a "cant rename, file already exists"
> sort of error....
I'm pretty sure the posix standard requires rename to
atomically remove and replace the target if it already
exists. But I don't have access to the standard, so
somebody else will have to check.
And using rename to delete the file is the correct way
to do because of the atomic behavioure. Deleting the old
file before renaming would introduce a race condition.
--
Kasper Dupont -- der bruger for meget tid paa usenet.
For sending spam use email***@***.com and email***@***.com
/* Would you like fries with that? */
|
| |
|
| |
 |
Kasper Dupont

|
Posted: 2004-5-1 3:13:00 |
Top |
java-programmer >> crash during file writing, how to recover ?
Roedy Green wrote:
>
> On Fri, 30 Apr 2004 18:25:02 +0200, Kasper Dupont
> <email***@***.com> wrote or quoted :
>
> >No need to delete the old one first. Renaming will
> >automatically delete the old file.
>
> Here is the sort of code I use to rewrite the contents of a file.
>
> // create a tempfile in the same directory as
> // the input file we have just processed.
> File tempfile = HunkIO.createTempFile ("temp", ".tmp",
> fileBeingProcessed );
> FileWriter emit = new FileWriter( tempfile );
> emit.write( result );
> emit.close();
> // successfully created output in same directory as input,
> // Now make it replace the input file.
> fileBeingProcessed.delete();
> tempfile.renameTo( fileBeingProcessed );
Well, I don't write java code I usually use C, so I don't
know exactly how those methods are implemented. But I
know it is impossible to delete a file using any kind of
handle, you need to use the name. So exactly what is the
meaning of `fileBeingProcessed.delete();'? Does it delete
whatever file has the name originally used to open
fileBeingProcessed?
In the next line it looks like fileBeingProcessed is a
string, but then you wouldn't be able to delete the file
the way it is done in the code.
>
> This effectively makes the tempfile disappear, but without the delete
> it would not make the old version disappear. Or would it?
If the renameTo method calls the rename system call, it
will make the old file disappear.
>
> It would be nice to have the delete/rename atomic.
You have it. At least on any posix compliant system you do.
--
Kasper Dupont -- der bruger for meget tid paa usenet.
For sending spam use email***@***.com and email***@***.com
/* Would you like fries with that? */
|
| |
|
| |
 |
Nick Landsberg

|
Posted: 2004-5-1 7:51:00 |
Top |
java-programmer >> crash during file writing, how to recover ?
Joseph wrote:
> Hi
> I'm writing a commercial program which must be reliable. It has to do
> some basic reading and writing to and from files on the hard disk,
> and also to a floppy.
>
>
> I have foreseen a potential problem. The program may crash
> unexpectedly while writing to the file. If so, my program should
> detect this during startup, and then (during startup) probably delete the
> data added to the file and redo the writing operation.
>
> Are file writing operations atomic ? ie when you write to a file,
> will it either do it succesfully, OR say half fail (eg write a few letters
> and not finish), OR not commit any changes to the file if a crash at
> this point occurs?
>
> My next question is how is this handled in commercial programming? I
> plan on writing a flag (say, a simple char) to another file (this
> would signal that a file write is about to begin), and then
> removing this char after the file writing operation is completed.
> Then on startup i just check the flags. if flag hasn't been removed a
> crash occurred, so have to open file and get rid of any garbage.
>
> Has anyone done anything similar b4? if so how did you handle this
> crash scenario. My application could totally stuff up if i don't
> handle this right.
>
> by the way, i'm using the java language and api. this might effect
> how files are written to, so i thought i should mention this.
>
>
> MANY THANKS
> Joseph
>
Just another followup, possibly about a condition that
you have not considered.
Do you need to guard against a hard-disk crash while
writing? If your program does not, by some definitions
this is "not reliable." (Is restoring from "last
week's backup" OK with the customer?)
You can only guard against a single hardware failure
at a time. As I mentioned elsethread, DBMS's use
a log file to log the changes. This log file must
be on a separate hardware device to guard against
a single hardware failure. Thus, either the logfile
or the data file survives. If the logfile is on the
device that fails, then, no problem. If the data-file
is on the device that fails, it may be reconstructed
from the last backup of the data files and applying
all the log-files since the backup.
I am not sure if the "rename" strategy mentioned by
other posters will be atomic over multiple physical
devices nor do I know about what size files you
are talking about. If it's several GB, then the
copy from one disk to another will take considerable
time. Then again, you may not need to be at this
level of paranoia. :)
--
"It is impossible to make anything foolproof
because fools are so ingenious"
- A. Bloch
|
| |
|
| |
 |
Kasper Dupont

|
Posted: 2004-5-1 14:07:00 |
Top |
java-programmer >> crash during file writing, how to recover ?
Nick Landsberg wrote:
>
> You can only guard against a single hardware failure
> at a time.
Actually you can guard against multiple hardware
failures, but it will get expensive.
>
> I am not sure if the "rename" strategy mentioned by
> other posters will be atomic over multiple physical
> devices
That depends. If you use a filesystem on a raid it
should be atomic. But raid is not 100% safe. With
an unfortunate sequence of events even a raid will
lose data. If we are talking independent filesystems
the rename will just report an error.
--
Kasper Dupont -- der bruger for meget tid paa usenet.
For sending spam use email***@***.com and email***@***.com
/* Would you like fries with that? */
|
| |
|
| |
 |
goose

|
Posted: 2004-5-1 17:16:00 |
Top |
java-programmer >> crash during file writing, how to recover ?
Joseph wrote:
<snipped>
> My next question is how is this handled in commercial programming? I
> plan on writing a flag (say, a simple char) to another file (this
> would signal that a file write is about to begin), and then
> removing this char after the file writing operation is completed.
> Then on startup i just check the flags. if flag hasn't been removed a
> crash occurred, so have to open file and get rid of any garbage.
Why not just write your 'dirty flag' in the same file?
<snipped>
goose
|
| |
|
| |
 |
Nick Landsberg

|
Posted: 2004-5-1 22:01:00 |
Top |
java-programmer >> crash during file writing, how to recover ?
Kasper Dupont wrote:
> Nick Landsberg wrote:
>
>>You can only guard against a single hardware failure
>>at a time.
>
>
> Actually you can guard against multiple hardware
> failures, but it will get expensive.
>
True. I inadvertantly left the word
"economically".
>
>>I am not sure if the "rename" strategy mentioned by
>>other posters will be atomic over multiple physical
>>devices
>
>
> That depends. If you use a filesystem on a raid it
> should be atomic. But raid is not 100% safe. With
> an unfortunate sequence of events even a raid will
> lose data. If we are talking independent filesystems
> the rename will just report an error.
>
--
"It is impossible to make anything foolproof
because fools are so ingenious"
- A. Bloch
|
| |
|
| |
 |
gerryq

|
Posted: 2004-5-1 22:30:00 |
Top |
java-programmer >> crash during file writing, how to recover ?
In article <email***@***.com>, Kasper Dupont <email***@***.com> wrote:
>I'm pretty sure the posix standard requires rename to
>atomically remove and replace the target if it already
>exists. But I don't have access to the standard, so
>somebody else will have to check.
>
>And using rename to delete the file is the correct way
>to do because of the atomic behavioure. Deleting the old
>file before renaming would introduce a race condition.
That sounds like a dangerous approach to me.
Why not rename the old file *first*, before writing the new one. Then
if the program starts and finds the most recently written file is
corrupt due to a crash, the last good file remains as a backup.
Renaming an existing file should be quick, and you can wait until it's
done before starting to write.
- Gerry Quinn
|
| |
|
| |
 |
Chris Smith

|
Posted: 2004-5-1 22:41:00 |
Top |
java-programmer >> crash during file writing, how to recover ?
For the most part, I think this thread demonstrates confusion caused by
cross-posting. We've got answers from people in
comp.lang.java.programmer answering as if this were entirely a Java
question and people from comp.os.linux.development.apps answering as if
it's a Linux question... and we don't know who's right!
Nevertheless, some clarification about Java:
Kasper Dupont wrote:
> Well, I don't write java code I usually use C, so I don't
> know exactly how those methods are implemented. But I
> know it is impossible to delete a file using any kind of
> handle, you need to use the name. So exactly what is the
> meaning of `fileBeingProcessed.delete();'? Does it delete
> whatever file has the name originally used to open
> fileBeingProcessed?
>
> In the next line it looks like fileBeingProcessed is a
> string, but then you wouldn't be able to delete the file
> the way it is done in the code.
Java's standard API class java.io.File is confusingly named. It
represents an abstract path name, not a file. Having a java.io.File
object doesn't even imply the existence of a file in the filesystem,
though File does expose an API method called exists() that tells you
whether this file exists in the filesystem or not. Certain operations
that deal with directory management (rename, delete, etc.) are
implemented for objects of the File class. So Roedy's calls make
perfect sense because they don't operate on a file descriptor, but
rather on a file name.
> If the renameTo method calls the rename system call, it
> will make the old file disappear.
Not surprisingly, it's not specified whether File.renameTo results in a
call to the rename system call. More surprisingly, it's not specified
whether File.renameTo will succeed if a file already exists by the
target name. That said, renameTo returns a success flag (which is ugly
in Java, but nevertheless happens). So it's entirely possible to write:
if (!newFile.renameTo(fileBeingProcessed))
{
fileBeingProcessed.delete();
newFile.renameTo(fileBeingProcessed);
}
Additional error checking would be nice in case the rename fails, for
example, on a Windows machine because of open file descriptors to the
file. Windows file handling doesn't separate the existence of a file
from its directory entry in the way POSIX does.
--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
|
| |
|
| |
 |
Kasper Dupont

|
Posted: 2004-5-2 1:11:00 |
Top |
java-programmer >> crash during file writing, how to recover ?
Gerry Quinn wrote:
>
> In article <email***@***.com>, Kasper Dupont <email***@***.com> wrote:
> >I'm pretty sure the posix standard requires rename to
> >atomically remove and replace the target if it already
> >exists. But I don't have access to the standard, so
> >somebody else will have to check.
I just checked susv3 does require rename to make
sure at any point in time, the target name will
refere to either the old or the new file. And if
rename fails the target must be unaffected.
> >
> >And using rename to delete the file is the correct way
> >to do because of the atomic behavioure. Deleting the old
> >file before renaming would introduce a race condition.
>
> That sounds like a dangerous approach to me.
>
> Why not rename the old file *first*, before writing the new one. Then
> if the program starts and finds the most recently written file is
> corrupt due to a crash, the last good file remains as a backup.
> Renaming an existing file should be quick, and you can wait until it's
> done before starting to write.
But then you'd have a window where no file exist with
the given name. The approach I suggested is safe. When
creating the new file first create it with a different
name. And when you have finished writing you rename it
such that it atomically replaces the old file.
There is nothing dangerous to it.
--
Kasper Dupont -- der bruger for meget tid paa usenet.
For sending spam use email***@***.com and email***@***.com
/* Would you like fries with that? */
|
| |
|
| |
 |
Kasper Dupont

|
Posted: 2004-5-2 1:15:00 |
Top |
java-programmer >> crash during file writing, how to recover ?
Chris Smith wrote:
>
> Not surprisingly, it's not specified whether File.renameTo results in a
> call to the rename system call. More surprisingly, it's not specified
> whether File.renameTo will succeed if a file already exists by the
> target name.
Well I don't know anything about Java. But I know that
the right way to do this requires use of the rename
system call to atomically remove the old file and
replace it with the new. If that is not what happens it
means either the Java program or the Java VM is broken.
--
Kasper Dupont -- der bruger for meget tid paa usenet.
For sending spam use email***@***.com and email***@***.com
/* Would you like fries with that? */
|
| |
|
| |
 |
CBFalconer

|
Posted: 2004-5-2 1:31:00 |
Top |
java-programmer >> crash during file writing, how to recover ?
Gerry Quinn wrote:
> Kasper Dupont <email***@***.com> wrote:
>
>> I'm pretty sure the posix standard requires rename to
>> atomically remove and replace the target if it already
>> exists. But I don't have access to the standard, so
>> somebody else will have to check.
>>
>> And using rename to delete the file is the correct way
>> to do because of the atomic behavioure. Deleting the old
>> file before renaming would introduce a race condition.
>
> That sounds like a dangerous approach to me.
>
> Why not rename the old file *first*, before writing the new one.
> Then if the program starts and finds the most recently written
> file is corrupt due to a crash, the last good file remains as a
> backup. Renaming an existing file should be quick, and you can
> wait until it's done before starting to write.
That is not his point. If a rename can fail because the target
file pre-exists, the delete/rename sequence has a hole between
delete and rename in which some other process can create that file
name, and cause a failure. This is a race condition. It is
especially likely to occur with database systems which inherently
tend to service multiple processes from the same database, and
have to 'take steps' to ensure the self-consistency of that
database.
One cure is to provide atomic operations, often by the use of
critical sections or other synchronization primitives. Another is
the concept of 'transactions'.
--
A: Because it fouls the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
|
| |
|
| |
 |
Nate Smith

|
Posted: 2004-5-2 2:32:00 |
Top |
java-programmer >> crash during file writing, how to recover ?
what about using copy first?
and what about exclusive access?
outline:
---------------------------------------------------------
actually first, grab the oldFile exclusively
if successful
then
open oldFile for Read
open saveFile for Write
copy oldFile to saveFile
close oldFile
close saveFile
if copy was successful
then
open oldFile for Write
open saveFile for Read
do the cloudy processing thing that rewrites oldFile
from the saveFile stuff & the "new stuff", whatever
the new stuff is (the changes, updates, etc.)
close oldFile
close saveFile
in case of crash in middle, saveFile should have the recovery
or if the copy step failed, oldFile is still unchanged,
and politely notify any interested parties
now release the exclusive hold on oldFile & let the race resume
else
wait until can grab oldFile exclusively in time,
where some waiting period has been established
to quit trying, and try again a "second" later
or
in case of time out, notify interested parties and
maybe quit thread with flag (duck out of the race)
NOTE:
presumably there are already other things in place elsewhere
that preserve the "new stuff" (changes, etc.) through crashes
-------------------------------------------------------------------
- nate, trying to keep from spilling his white russian
|
| |
|
| |
 |
Calum

|
Posted: 2004-5-2 7:00:00 |
Top |
java-programmer >> crash during file writing, how to recover ?
Chris Smith wrote:
> Not surprisingly, it's not specified whether File.renameTo results in a
> call to the rename system call. More surprisingly, it's not specified
> whether File.renameTo will succeed if a file already exists by the
> target name. That said, renameTo returns a success flag (which is ugly
> in Java, but nevertheless happens). So it's entirely possible to write:
>
> if (!newFile.renameTo(fileBeingProcessed))
> {
> fileBeingProcessed.delete();
> newFile.renameTo(fileBeingProcessed);
> }
Just to be inconsistent, the Microsoft "rename" function specifically
requires "The new name must not be the name of an existing file or
directory". It makes some sense - I wouldn't expect a function called
"rename" to delete a file, but I can see situations where either
behaviour would be desired.
So it's possible Java will have different behaviour on Windows and
POSIX, though I can't be bothered to check this.
I guess for ultra-safety, the old file could be renamed to something
else, before renaming the new file to the target filename. Of course
then you'd just clutter up the directory with old files, but there are
circumstances where you want to be able to roll back.
Calum
|
| |
|
| |
 |
Norm Dresner

|
Posted: 2004-5-2 8:47:00 |
Top |
java-programmer >> crash during file writing, how to recover ?
"goose" <email***@***.com> wrote in message
news:email***@***.com...
> Joseph wrote:
>
> <snipped>
>
> > My next question is how is this handled in commercial programming? I
> > plan on writing a flag (say, a simple char) to another file (this
> > would signal that a file write is about to begin), and then
> > removing this char after the file writing operation is completed.
> > Then on startup i just check the flags. if flag hasn't been removed a
> > crash occurred, so have to open file and get rid of any garbage.
>
> Why not just write your 'dirty flag' in the same file?
>
Because if the power fails during this write-op, the entire track of the
media may be lost.
The real question is, what else do you need to hold up your pants
besides a belt and suspenders?
Norm
|
| |
|
| |
 |
| |
 |
Index ‹ java-programmer |
- Next
- 1
- ClassCastException in ColorModel.getAlphaSometimes I get this exception. Anyone know why? Thanks!
Uncaught error fetching image:
java.lang.ClassCastException: java.lang.Object
at java.awt.image.ColorModel.getAlpha(ColorModel.java:854)
at java.awt.image.ColorModel.getRGB(ColorModel.java:899)
at
sun.awt.image.ImageRepresentation.convertToRGB(ImageRepresentation.java(Comp
iled
Code))
at
sun.awt.image.ImageRepresentation.setPixels(ImageRepresentation.java(Compile
d
Code))
at
java.awt.image.AreaAveragingScaleFilter.accumPixels(AreaAveragingScaleFilter
.jav
a(Compiled Code))
at
java.awt.image.AreaAveragingScaleFilter.setPixels(AreaAveragingScaleFilter.j
ava:
241)
at sun.awt.image.PixelStore8.replayLines(PixelStore8.java:68)
at sun.awt.image.PixelStore.replay(PixelStore.java(Compiled Code))
at sun.awt.image.PixelStore.replay(PixelStore.java:176)
at
sun.awt.image.InputStreamImageSource.updateFromStore(InputStreamImageSource.
java
:333)
at
sun.awt.image.InputStreamImageSource.doFetch(InputStreamImageSource.java:282
)
at sun.awt.image.ImageFetcher.fetchloop(ImageFetcher.java:204)
at sun.awt.image.ImageFetcher.run(ImageFetcher.java:172)
- 2
- Java / JSP hostingHi!
Im trying to find a good (and low budget) host for my website that runs
JSP and java servlets, that interact with paypal. They also use JCE
and Javamail.
Im currently hosted with godaddy, but I think I need to jump away from
them because they dont allow me to interact with paypal from a java
servlet.
I was wondering if anyone has had any good experiences with ANY hosting
company for these issues, specifically
http://www.adsinmedia.com/JSP-Servelets-Hosting-India.html
http://www.visionwebhosting.net/
http://www.belahost.com/pp/index.php
thanks for any feedback!
- 3
- passing -D argument with white spaces on UNIXHi,
I try to pass a value to overwrite a value defined in the property
file by using following command on unix:
java -DMYENV="my value here" javaClass...
java cannot interpret it correctly, how can I get around it?
Thanks
WM
- 4
- Serialize Applet to a web server via Servlet ProblemHi,
I try to Serialise an Applet on my WebServer, i convert Object to
ByteArray, before sending it to webserver.
There is 2050 bytes in byte array on my applet before sending it, and
2062 bytes in byte array on tomcat !
Where is my mistake ?
Regards
Philippe
Applet
void WriteApplet(String filename)
{
ObjectOutputStream out;
System.out.println("Debut Test WRITE APPLET...");
//Serialisation de la frame
try
{
String m_URL=new
String("http://172.16.0.101:8080/test/servlet/servletgraph.XXServlet");
String string4=m_URL;
System.out.println("w01 "+string4);
URL u=new URL(string4);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(this);
oos.flush();
oos.close();
byte b[] = baos.toByteArray();
HttpURLConnection urlc = (java.net.HttpURLConnection)
u.openConnection();
// Set the Post (true) or Get (false) method.
urlc.setDoOutput(true);
urlc.setDoInput(true);
urlc.setUseCaches(false);
urlc.setAllowUserInteraction(false);
urlc.setRequestProperty("Content-Type",
"application/octet-stream");
String lengthString = String.valueOf(baos.size());
urlc.setRequestProperty("Content-Length", lengthString);
System.out.println("Object is avant ecriture " + lengthString + "
bytes");
out = new ObjectOutputStream(urlc.getOutputStream());
out.write(b);
if (urlc.getResponseCode() != HttpURLConnection.HTTP_OK) {
System.out.println("Error...");
} else {
System.out.println("I have now access to the stream...");
// blaha balaaha blaahahaha
}
out.flush();
out.close();
System.out.println("Fin Test WRITE APPLET...");
}
catch (IOException ioe) {
System.err.println(ioe);
ioe.printStackTrace();
}
}
-------------------------------------------------------------------------
Servlet
public void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException
{
System.out.println("XXServlet doPost X1 "+new Date());
boolean debug=true;
InputStream in = req.getInputStream();
byte[] bufimage=null;
bufimage = new byte[4 * 1024]; // 4K buffer
int len;
RandomAccessFile f = new
java.io.RandomAccessFile(req.getRealPath("/")+"xxservlet", "rw");
int size = req.getIntHeader("content-length");
bufimage = new byte[size]; // 4K buffer
if(debug) System.out.println("XXServlet bytearray02 "+size);
int nb=0;
while ((len = in.read(bufimage, 0, bufimage.length)) != -1)
{
if(debug) System.out.println("XXServlet bytearray03
content-length "+len);
f.write(bufimage, 0, len); //Fichier
nb=+len;
}
if(debug) System.out.println("XXServlet bytearray05 "+nb);
f.close();
if(debug) System.out.println("XXServlet write04 ");
}
}
- 5
- metadata and stored proceduresHi everybody,
I use a CallableStatement to run my stored procedure, and I would like
to retrive the columns name of the result.
So I try to use the getMetaData method of my CallableStatement, but it
returns me null futhermore than le callablestatement returns data.
How can I do to retrieve my columns names ?
Thanks
Thomas
- 6
- How about to lauch a new thread in a constructor?I read one piece of code written by somebody and behold interesting
class as below:
class SomeFramework {
public SomeFramework() {
...
DameonThread dameon = new DameonThread();
dameon.start();
}
private doSomething() {
...
}
private class DameonThread extends Thread {
public void run() {
...
doSomething();
...
}
}
}
As you can see, in the constructor of SomeFramework, one thread is
launched and that thread will call the SomeFramework instance's private
method. Perhaps the author design this code to make the client code
easy. The client just call "new SomeFramework()" and everything is done.
No need to coding like
SomeFramwork framework = new SomeFramework();
framework.lauch();
However, the problem is that it is possible that when the dameon is
started, CPU will go into run and call doSomething() of the instance of
SomeFramework. But, at that time, the constructor is not returned. Is it
reasonable to call a method of a un-instanstized object? Curiously, this
code works well all the time. Luckily, before dameon is started, all
member variables are instantized in constructor, but I really think this
code is ugly and should be avoided.
- 7
- AWT/Swing layout behavior?I am having trouble figuring out the right way to use the GridBagLayout
class.
I have some sample code (see below) that I _expected_ would take the two
components added to the frame and always make them the same size, arranged
vertically.
What happens instead is that when one of the two components is a Panel or
JPanel (and possibly other container types...those are the two I tested),
if that component contains another component, it takes up more than half
of the frame.
Reading the documentation, I am under the impression that the
GridBagLayout class automatically allocates the dimensions of a given
component according to the weight assigned to it in the GridBagConstraints
class set for the component. Thus, since these two components have the
same weights, they should always be equally sized. But for some reason,
having the container actually contain something affects this.
The sample code only adds one item, and the difference in size is
noticeable but not very large. However, this came up in a more complex
situation, where a larger number of controls are added. In that case, the
size difference is proportionally larger as well, resulting in effective
relative weights more like 3 or 4 to 1.
Is there a way to get the GridBagLayout class, or some other built-in
LayoutManager, to do this sort of auto-sizing where the relative weights
will always actually stay equal?
Thanks!
Pete
p.s. Something I ran into while putting the sample code together is that
sometimes when I'd run the code, the button would not show up. It'd be
briefly visible, and it would show up again once the window is resized.
But to start with, it's not visible. Is there some basic flaw in the way
I'm creating this UI that is leading to this erratic behavior? Or am I
just looking at some sort of run-time bug?
import java.awt.*;
import javax.swing.*;
import javax.swing.border.*;
public class TestPanel
{
/**
* @param args
*/
public static void main(String[] args)
{
Frame frame = new Frame("TestPanel");
GridBagLayout grid = new GridBagLayout();
GridBagConstraints constraints = new GridBagConstraints();
JPanel panel;
frame.setLayout(grid);
constraints.fill = GridBagConstraints.BOTH;
constraints.gridwidth = GridBagConstraints.REMAINDER;
constraints.weightx = 1;
constraints.weighty = 1;
panel = new JPanel();
panel.setBorder(new LineBorder(Color.BLACK));
panel.add(new Button("Test"));
frame.add(panel);
grid.setConstraints(panel, constraints);
panel = new JPanel();
panel.setBorder(new LineBorder(Color.BLACK));
frame.add(panel);
grid.setConstraints(panel, constraints);
frame.setSize(240, 480);
frame.setVisible(true);
}
}
- 8
- Memory utilizationI was trying to profile the following piece of code using NetBeans:
public static void main(String[] args)
{
Map<String, String> map = new HashMap<String, String>();
for( int i = 0; i < Integer.MAX_VALUE; ++i )
{
map.put(Integer.valueOf(i).toString(),
Integer.valueOf(i).toString());
}
}
I set my max and min heap size to be 1GB. I find that the program dies
after having created 4M entries (at which point the heap used is at
1GB) although the memory used by the objects as indicated by the
Netbeans memory profiler is the following:
String -- 48MB
char[] -- 48 MB
HeapCharBuffer -- 45MB
Integer -- 19MB
HashMap$Entry -- 19MB
This totals to less than 200 MB and the rest of the objects are at 0%
of the total used memory at most another 200MB. How come the heap
usage is at 1GB at this point of time? I am extremely confused. Could
someone please explain what might be going on?
Thanks
A
- 9
- why not Java?
The company I am working for hired a guy three months ago which is a strong M$
fan, and I am a Java fan and also a SCJP, but somehow he and my ex-boss deceide
we should have a standard language for future projects (we are using VB6
currently), so he said we all should using VB.Net/ASP.Net now, and he said I
should forget what I know about Java/JSP. When I said "Since VB.Net/ASP.Net are
both new to us, why cannot we give Java a chance?", but he said ".Net is the
future." and from his eyes, he seems want to say "you are fired if you do not
want move to .Net."
Should I find a new Java job?
- 10
- executing a jsp from a java applicationI have a jsp that checks which clients that are connected. This works
well! When I from a browser loads the jsp page, information about how
many clients is connected is presented in the browser and also
appended to a logfile on the Windows 2003 server machine.
Now I want to write a Java application that is to always be running on
the server. In this Java application there is a timer that expires,
lets say every 10 minutes. When the timer expires a certain method
(lets call it timerEventHandler) in the java application executes.
Question:
How can timerEventHandler execute the jsp so that information about
connected clients is appended to the logfile at every 10 minute?
I would really like som code for this. I have searched the Internet
for a couple of days now. I tried using JEditorPane and construct a
minimal webbrowser that would load the jsp page, but after trying
several examples of java webbrowsers it seems that I am behind proxys,
firewalls, or whatever that makes it impossible for me to load a
webpage. I can however start IE and load the page. Does anyone have an
idea what can be done?
thanks
- 11
- Java GUI lag during window resizing on laptopI was messing around with a Java application I developed on my latop
and noticed something interesting. There seems to be lag with resizing
the windows and resizing the panels via the dividers. BUT this lag
only occurs when my laptop runs on the battery, or, rather, you don't
see this when it is connected to an AC power source.
This also occurs in some other Java applications I downloaded and
tested. But there are others that do not have this behavior.
I am not sure why this happens. But what I do know is that some laptop
manufacturers reduce power consumption by limiting hardware (and
software) factors, including slowing the CPU clock -- not sure if that
is the cause.
Not sure if anyone can give any input to what might be causing this --
an is there a way to rewrite/manupilate my code so that it does not
happen?
- 12
- No window control in an Application WindowHi,
After following a JFACE eclipse example, i created a new class that
extends ApplicationWindow that create a nice window with tool bar, menu
bar and status bar. That's great.... but my window doesn't have window
controls to minimize or iconify it, only the quit element (the cross)!
Does anybody know which attribute i have to set to have window
controls?
Thx
0o.
- 13
- I am a Java Virgin! I need your support.I do agree with both of you, I probably wasnt clear. I just meant I
found pascal good for teaching me the basics of programming (loops,
conditions, passing parameters etc) but yes OO is a lot different and
requires a different mind set when is comes to solving a problem. Also I
agree on using BlueJ to get into Java and the OO side of programming. I
used this when first learning and still do on some occassions as it is
very clear in laying out classes and how they relate to each other, also
it's good for inspecting the properties of a class while the code is
running.
Michael Redlich wrote:
> Daniel Dyer wrote:
>
>>I also went from Pascal (and BASIC before that) to Java. While Pascal may
>>be easier to pick-up, the problem with going from procedural to OO is that
>>you have to unlearn a lot of things because it is a different way of
>>thinking. The key to feeling comfortable in Java is having a good grasp
>>of objects. If you come from a procedural background you have
>>preconceptions about how to program that could be a hinderance in the OO
>>world. Ways of writing good code in Pascal are bad habits in Java.
>
>
> Dan:
>
> I, too, learned procedural programming before OOP. I remember learning
> FORTRAN IV on an IBM mainframe with keypunch cards. From there it was
> BASIC, Pascal, C, then finally C++ and Java.
>
> I understand and agree with what you said about switching from
> procedural to OOP. However, I also think that it made me appreciate
> OOP more.
>
> A few years ago, Bjarne Stroustrup was interviewed about which language
> would be better for a new programmer to learn - C or C++. I was a bit
> surprised that he recommended C++. I suppose that I was thinking about
> the learning curve for the STL, but then again, who says that a new
> programmer would necessarily have to use the STL right away?
>
> Since the OP was very new to any kind of programming, I recommended
> that he learn the basics of any programming language: loops,
> conditionals, etc., and learn how to avoid potential pitfalls such as
> inadvertantly writing infinite loops. I think that's more important
> regardless of which programming language he chooses.
>
> Sincerely,
>
> Mike.
>
> ------
> ACGNJ Java Users Group
> http://www.javasig.org/
>
- 14
- why is remove(myPanel2) not working?Hello,
For some reason the
contentArea.remove(myPanel3);
works but the
contentArea.remove(myPanel2);
does not - any ideas please?
(happy to post the whole code if this helps)
Cheers
Geoff
if (textIndex == 0)
{
contentArea.remove(myPanel2);
contentArea.remove(myPanel3);
myPanel3 = new JPanel();
myPanel3.setBackground(Color.white);
JLabel endMessage = new JLabel("Thank you - all questions
answered");
myPanel3.add(endMessage);
contentArea.add(myPanel3, BorderLayout.SOUTH);
setContentPane(contentArea);
contentArea.setVisible(true);
}
- 15
- New Software Development Articles DirectoryA new links directory of articles related to software development is
"under construction" on http://www.softdevarticles.com/
Please feel free to use it in you next research and to contribute with
your articles on Java.
|
|
|