| Changing Tomcat configuration |
|
 |
Index ‹ java-programmer
|
- Previous
- 1
- 1
- question about compiling java with textpadHow do i set a classpath in the javac? its not paying attention to the
classpath I have set at the environment level. This is windows 2000.
I go to configure->preferences->tools->compile java
I see $file in the parameters. Not able to do this:
-classpath <path> $file
and i get the standard javac error where it lists the options.
- 2
- starting a weblogic servlet?Hello,
I have written a basic servlet of the form
public final class MyServlet extends HttpServlet
{
public void init(ServletConfig config) throws ServletException
{
super.init(config)
/* do other stuff */
}
}
My question is, what do I need to do so that the "init" method is
invoked upon servlet (i.e. Weblogic) startup? I'm using Weblogic 5.1
sp 12 on Sun Solaris.
Thanks for your help, - Dave
- 2
- Returning value from deep recursionI have the following code
***********************************
/**
* Recurses through schema finding the first instance of the
element name
* @param schemaElement - current element being compared from
schema
* @param checkElement - element to be checked against i.e. the
node selected in the gui
* @return the element in schema which matches the checkElement
*/
private Element findElementNameMatch(Element schemaElement, Element
checkElement)
{
// Get list of children
List listOfChildren = schemaElement.getChildren();
// If element has children
if(listOfChildren.size() != 0)
{
// Recurse through all elements under this one
for(int x=0; x < listOfChildren.size(); x++)
{
// Get child element
Element childElement = (Element) listOfChildren.get(x);
if(childElement.getName() == checkElement.getName())
{
return(childElement);
}
findElementNameMatch(childElement,checkElement);
}
}
return(null);
}
***********************************
The method is trying to find an element in an xml document that matches
a given name.
Can anyone give me tips on how to go about returning a value from deep
recursion to the first recursion of that particular method, so it can
return that value to the method that called it.
And also quite importantly how to stop any recursions after a match has
been found. EG a target element is found and returned, but how can i
stop the recursion going on to check elements under this element.
So far i have only achieved the two by creating a global variable and
flag, the variable is initialised when the match is found, and flag is
set to true so no more recursions are done afterwards.
- 2
- Null pointer exception while trying to repaint the component that displays a buffered image when the component is scrolled using scroll barI am trying to repaint a component that displays a buffered image when
the component is scrolled. I get the following error:
[java] java.lang.NullPointerException: NullSD does not handle
this operation
[java] at sun.java2d.NullSurfaceData.getRaster(Unknown Source)
[java] at sun.java2d.loops.OpaqueCopyAnyToArgb.Blit(Unknown
Source)
[java] at sun.java2d.loops.GraphicsPrimitive.convertFrom(Unknown
Source)
[java] at sun.java2d.loops.MaskBlit$General.MaskBlit(Unknown
Source)
[java] at sun.java2d.loops.Blit$GeneralMaskBlit.Blit(Unknown
Source)
[java] at sun.java2d.pipe.AlphaPaintPipe.renderPathTile(Unknown
Source)
[java] at sun.java2d.pipe.SpanShapeRenderer
$Composite.renderBox(Unknown Source)
[java] at sun.java2d.pipe.SpanShapeRenderer.spanClipLoop(Unknown
Source)
[java] at sun.java2d.pipe.SpanShapeRenderer.renderSpans(Unknown
Source)
[java] at sun.java2d.pipe.SpanShapeRenderer.renderPath(Unknown
Source)
[java] at sun.java2d.pipe.SpanShapeRenderer.fill(Unknown Source)
[java] at sun.java2d.pipe.ValidatePipe.fill(Unknown Source)
[java] at sun.java2d.SunGraphics2D.fill(Unknown Source)
[java] at
i3dea.ditto.DocumentImageDisplay.paintZone(DocumentImageDisplay.java:
256)
[java] at
i3dea.ditto.DocumentImageDisplay.paintComponent(DocumentImageDisplay.java:
467)
[java] at javax.swing.JComponent.paint(Unknown Source)
[java] at javax.swing.JComponent.paintChildren(Unknown Source)
[java] at javax.swing.JComponent.paint(Unknown Source)
[java] at javax.swing.JViewport.paint(Unknown Source)
[java] at javax.swing.JComponent.paintChildren(Unknown Source)
[java] at javax.swing.JComponent.paint(Unknown Source)
[java] at javax.swing.JComponent.paintWithOffscreenBuffer(Unknown
Source)
[java] at javax.swing.JComponent.paintDoubleBuffered(Unknown
Source)
[java] at javax.swing.JComponent._paintImmediately(Unknown
Source)
[java] at javax.swing.JComponent.paintImmediately(Unknown Source)
[java] at javax.swing.RepaintManager.paintDirtyRegions(Unknown
Source)
[java] at javax.swing.SystemEventQueueUtilities
$ComponentWorkRequest.run(Unknown Source)
[java] at java.awt.event.InvocationEvent.dispatch(Unknown Source)
[java] at java.awt.EventQueue.dispatchEvent(Unknown Source)
[java] at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
[java] at
java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
[java] at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
[java] at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
[java] at java.awt.EventDispatchThread.run(Unknown Source)
Thanks
Mangai
- 3
- model to xmlHi,
We have "Objects" that relate to each other in a parent-child
relationship. Also these objects can have references to ther objects
that is not a parent. Let me give you all an example.
I have the following parent-child relationship between objects,
Object A=1
|
-------------
| |
Object B=1 Object C=1
|
-------------
| |
Object D=1 Object D=2
Note: The number is the identity when we have more than one object of
the same type.
"Object A=1" is parent to child "Object B=1".
We have the same relationship for "Object D=1". "Object A=1" is parent
to "Object B=1" which is parent to "Object D=1". The path to "Object
D=1" is "Object A=1,Object C=1,Object D=1".
Also "Object B=1" can have a reference to "Object D=2". The
"reference"-attribute in "Object B=1" has the following path,
"Object A=1,Object C=1,Object D=2"
My question is if there is a tool where I can graphically create my
model ( see my nice one !!!) and from that generate an xml file ( or
xmi).
Requirements:
* It is important that when I create "Object B=1" it must be possible
for "Object B=1" to know that it's parent is
"Object A=1". When the hirarchy grows the child at the end should know
the whole path to itself.
* It is also important that a reference to an Object D=2 is created as
"Object A=1,Object C=1,Object D=2"
Has anyone done something similar? Any open-source tools for this? All
ideas/questions are welcome.
BR
//Mikael
- 3
- java vs ircHi
Im at a crossroad as to how to implement a webchat. I have the option of
building a chat using a standard IRC server saving me the trouble of
implementing it myself, OR i can write the server myself in Java giving me
full customizability. I would tend to go with the latter approach however im
rather concerned about performance. By performance im thinking bandwidth and
server load. So my question is: is it possible to build a chat server in
Java that is
a) better or equal to an IRC server utilizing bandwidth, and
b) better or equal to an IRC servers server load?
Im thinking performance wise that IRC would be better, but im not sure
whether this is true so im asking if anyone can give me some input as to why
one solution would be better than the other.
Thanx
Mike
- 3
- Hibernate on delete cascadeI use Hibernate and I am not able to do cascade delete.
After I create a project I have:
select * from project;
uid | name | shortdescription
-----+------+-----------------
1 | nc | NC Web application
(1 row)
After I subscribe to the project I have:
select * from subscription;
uid | account | project | role
-----+---------+---------+------
1 | 1 | 1 | 1
(1 row)
When I delete the project with a simple session.delete
try {
session.delete(project);
session.flush();
} catch (HibernateException e) {...
the row is deleted in the table "project"
but the row stays in table "subscription". Only the column entry "project" is set to null.
select * from subscription;
uid | account | project | role
-----+---------+---------+------
1 | 1 | | 1
(1 row)
I want the row to be deleted, how do I do that?
My two tables one for Projects and one for Subscriptions
<hibernate-mapping>
<class name="org.cobra.persistence.Project" table="project">
<id name="id" column="uid" type="long">
<generator class="increment"/>
</id>
<property name="name">
<column name="name" sql-type="char(32)" not-null="true"/>
</property>
<property name="shortDescription">
<column name="shortDescription" sql-type="char(256)" not-null="true"/>
</property>
<set name="subscriptions" table="subscription" cascade="all-delete-orphan">
<key column="project"/>
<one-to-many class="org.cobra.persistence.Subscription"/>
</set>
<set name="subscriptionsRequested" table="subscriptionRequest" cascade="all-delete-orphan">
<key column="project"/>
<one-to-many class="org.cobra.persistence.SubscriptionRequest"/>
</set>
</class>
</hibernate-mapping>
<hibernate-mapping>
<class name="org.cobra.persistence.Subscription" table="subscription">
<id name="id" column="uid" type="long">
<generator class="increment"/>
</id>
<many-to-one name="account" column="account" cascade="all" class="org.cobra.persistence.Account" />
<many-to-one name="project" column="project" cascade="all" class="org.cobra.persistence.Project" />
<many-to-one name="role" column="role" cascade="all" class="org.cobra.persistence.Role" />
</class>
</hibernate-mapping>
- 3
- Memory Leakage drawing Images from Stream - Minimum exampleOk folks
I posted this a number of times ago,but never posted a minimum code
example for people to look at.
I was trying to load and draw images from a Mjpeg-Stream, reading from
the stream in a different thread.
This is the thread where the images are read by:
public class Axis2420
{
private HttpURLConnection hurlconnection = null;
private DataInputStream datainstream = null;
private String serialNumber = null;
private boolean connected = false;
private Frame dummy = null;
private Image image = null;
private String MJpegStreamUrl = null;
Runnable decodingThread = null;
public void SetURL(String url)
{
MJpegStreamUrl = url;
}
public boolean Connect()
{
if(MJpegStreamUrl == null)
{
System.out.println("Error: Empty Camera URL String");
return false;
}
try
{
URL streamurl = new URL(MJpegStreamUrl);
hurlconnection = (HttpURLConnection)streamurl.openConnection();
hurlconnection.setReadTimeout(10000);
//hurlconnection.setUseCaches(false);
InputStream instream = hurlconnection.getInputStream();
connected = true;
BufferedInputStream bis = new BufferedInputStream(instream);
datainstream = new DataInputStream(bis);
} catch(IOException e)
{
System.out.println("Fehler");
try
{
hurlconnection.disconnect();
Thread.sleep(60);
}
catch(InterruptedException ie)
{
hurlconnection.disconnect();
Connect();
}
catch(Exception ex)
{return false; }
System.out.println(e.getMessage());
return false;
}
return true;
}
//run method of the reading thread
public void run()
{
//test if still connected
if(!connected)
return;
try
{
//decode stream
if(connected)
{
Image i = null;
//ImageIO.setUseCache(false);
long before,after;
while(!Thread.currentThread().isInterrupted())
{
i = null;
String header;
int k = 0;
do
{
header = datainstream.readLine();
//System.out.println("Zeile: " +header);
}
while(++k < 3);
int j = (new Integer(header.substring("Content-Length:
".length()))).intValue();
datainstream.readByte();
datainstream.readByte();
// datainstream.readLine();
imageJPG = new byte[j];
datainstream.readFully(imageJPG, 0, j);
byte tail[] = new byte[4];
datainstream.readFully(tail,0,4);
i =
Toolkit.getDefaultToolkit().createImage(imageJPG,0,imageJPG.length);
image = i;
i = null;
fireChange(); //calls the stateChanged() method in
the class 'MainProgram' below
image = null;
i = null;
Thread.currentThread().sleep(10);
}
}
}
catch(Exception ex)
{
ex.printStackTrace();
}
finally
{
try {
datainstream.close();
} catch(Exception ex)
{
ex.printStackTrace();
}
}
}
//for the listening objects so they can fetch the latest image
public Image getLatestImage()
{
return image;
}
<....>
}
Once a new image has arrived, the fireChange() method calls this method
on the MainProgram class:
class MainProgram
extends JFrame
implements Runnable,ChangeListener
{
public static String WINDOW_TITLE = "BINO GESTENERKENNUNG";
public static int WINDOW_WIDTH = 640;
public static int WINDOW_HEIGHT = 480;
public static final int CAMERA_LEFT = 0;
public static final int CAMERA_RIGHT = 1;
//public static final String leftCameraURL =
"http://192.168.1.51/axis-cgi/mjpg/video.cgi?resolution=704x576&compression=25&clock=0&date=1&fps=10";
//public static final String rightCameraURL =
"http://192.168.1.51/axis-cgi/mjpg/video.cgi?resolution=704x576&compression=25&clock=0&date=1&fps=10";
public static final String leftCameraURL =
"http://192.168.1.51/axis-cgi/mjpg/video.cgi?resolution=352x288&compression=70&date=1&fps=5";
public static final String rightCameraURL =
"http://192.168.1.51/axis-cgi/mjpg/video.cgi?resolution=352x288&compression=100&date=1&fps=5";
Image currentLeftImage;
Image currentRightImage;
Graphics leftImageGraphics;
Graphics rightImageGraphics;
Graphics leftCameraGraphics;
Graphics rightCameraGraphics;
byte[] currentLeftImageJPG;
byte[] currentRightImageJPG;
BufferedImage testImage;
Axis2420 leftCamera = null;
Axis2420 rightCamera = null;
CameraCanvas leftCameraCanvas = null;
CameraCanvas rightCameraCanvas = null;
Runnable drawThread = null;
boolean readyToDraw = false;
boolean newImage = false;
long frameRateLeft = 0,frameRateRight = 0;
long frameTimesLeft[],frameTimesRight[];
//vPointerDetector leftImagePointer;
//vPointerDetector rightImagePointer;
vPointerDetector imagePointer;
boolean updateLeftImage,updateRightImage;
<.....lots of meaningless stuff.......>
public void stateChanged(ChangeEvent e)
{
currentRightImage = rightCamera.getLatestImage();
rightCameraCanvas.SetUpdate(true); //otherwise paintComponent()
of the JCanvas won't draw the image
rightCameraCanvas.SetImage(currentRightImage);
rightCameraCanvas.repaint();
currentRightImage = null;
currentRightImageJPG = null;
}
}
}
} //end of MainProgram class
Basically, all the stateChange method does is getting the image from the
image-reading thread ('rightCamera' of type Axis2420) after
rightCamera called fireChange(). The image is passed to an object of the
class CameraCanvas which derieves from JCanvas. After that, we cast
repaint() on the CameraCanvas (rightCameraCanvas.repaint() ).
This is the CameraCanvas that is responsible for drawing:
public class CameraCanvas extends JPanel
{
private Image image = null;
boolean drawNext = false;
boolean readyForNext;
public void paintComponent(Graphics g)
{
if(drawNext == true)
{
readyForNext =
g.drawImage(image,0,0,getSize().width,getSize().height,this);
//image.flush();
image = null;
//g.dispose();
//imageBuffered.flush();
drawNext = false;
}
}
//indicates that there is a new image
public void SetUpdate(boolean up)
{
drawNext = up;
}
//passes a new image to the Canvas
public void SetImage(Image i)
{
image = i;
}
}
The program draws the stream correctly and is smooth like butter.
However, there is a HUGE memory leak somewhere that raises the memory
usage by about 40MBytes per second. If I remove the call to
readyForNext = g.drawImage(image,0,0,getSize().width,getSize().height,this);
in the CameraCanvas thread, the leak will go down to about 40 kbyte /
second. If I leave it in and post a System.gc() call afterwards, the
leak will also go down.
I think that I'm somewhat polling the AWTEvent thread which lots of
copies of images waiting to be drawn. Also using
Toolkit.getDefaultToolkit().createImage(imageJPG,0,imageJPG.length);
spawns abouth 4 ImageFetcher threads which I think are the reason for
the small memory leak.
Now the question: What can I do about it?
It seems that the garbage collection isn't called after drawing an image
and casting it manually via System.gc() slows everything down a lot.
Using ImageIO.read)() instead of the Toolkit seems to remove the small
leak, but not the big one for drawing. And it tends to be slower since
it's blocking and keeping the Axis2420 thread from reading from the stream.
My thesis is due soon, so pleease have a look at it again.!!
Thanks in advance!!!
- 4
- a simple java timerJust wondering, has anyone here ever used java.swing.timer if so, have you
got any examples? i cant seem to find many on google :s
- 8
- [eclipse] export with referenced librariesHello,
I am trying to export a project in jar format so that I can run it on
different machines. . I got a NoClassDefFoundError exception because
it requires referenced libraries (in this case, it is the MINA). Would
anyone please tell me how to export with referenced libraries?
Thanks
-k
- 11
- ports/81272: JDK 1.5 port doesn't build.Synopsis: JDK 1.5 port doesn't build.
Responsible-Changed-From-To: freebsd-amd64->freebsd-java
Responsible-Changed-By: arved
Responsible-Changed-When: Fri Nov 25 16:57:03 GMT 2005
Responsible-Changed-Why:
Refile, this looks like a ports issue.
Assign to port maintainers
http://www.freebsd.org/cgi/query-pr.cgi?pr=81272
- 13
- IndexOf for whitespaceWhat if you wanted the indexOf either a space or a \n whichever came
first. Have you a slick way to code that?
Pedestrian possibilities include:
1. pair of indexOfs , take minimum ignoring <0s.
2. Write a loop that uses charAt
3. write a regex
Is there a slick way to handle it?
--
Roedy Green, Canadian Mind Products
The Java Glossary, http://mindprod.com
- 14
- API 1.5.0 DownloadHi all,
I am new to the Mac and am looking for a download of the
jdk 1.5.0 api. I cannot find a tarball or zip file on the
Sun site that I can download so I can use the reference when
I am offline.
Suggestions?
Thanks,
Bob
- 15
- McDonalds/RoundTable, design&farm (was: I'm still waiting for ...)> From: email***@***.com (Michael Sullivan)
> ... instead of looking for exactly and precisely the kind of work
> that you have done in the distant past, ...
You're displaying a serious misconception. I'm available for any legal
work where I'd be doing something actually useful so that it would be
worth paying me to do it. It's the employers who refuse to even
consider people who haven't done exactly the same kind of work before.
> Go work at McDonalds
I tried that, when I had less than one year work experience. The
manager at the McDonalds on El Monte near El Camino Real told me that
because I have a college degree he won't consider me for employment
because he'd waste two months training me and then I'd find a better
job elsewhere and he'd be out the expense of training. Later that year
I got a job at Round Table Pizza on University in Palo Alto, where a
ditzy redhead Mrs. Masinter wasn't watching where she was going and
collided with my car and then freaked out seeing the car parts strewn
on the pavement, apologizing, exchanging insurance info, then she drove
off before giving me a chance to inspect the damage and see that all
the damage was to *her* car, not mine. Anyway, Round Table fired me
because I suffer a learning disability, unable to memorize the prices
on the menu. A year or two later I was sitting at a terminal at the
A.I. lab doing my usual work for free, and occasionally running FINGER
to see who else was around, when I saw Larry Masinter logged in, so I
wwnt over and asked if he was in any way related to that ditzy driver,
and indeed that was his former wife. He showed me Lisp for the first
time, impressed me, and after Hans Moravec explained the REP loop to me
I was forever going strong with Lisp.
> or a factory
That's not a good idea. I have very poor muscle coordination, can't
write legibly, can't do sports at all, take ten times as long as anyone
else to do a simple mechanical task in metal/wood shop in school and
still the result is cruddy, need extra space on both sides of car when
I'm driving because I can't judge distance between car and parket cars,
break almost anything physical I try to work on, did I tell you about
the disaster when I tried to do work on my car (tune-up, and lubricate
the air-duct wire-in-sleeve control cables)?
> a lot more brainpower goes into defining the problems that explicitly
> than into the actual coding,
Much of my work at Stanford was like that. Unfortunately there's no way
to express that with buzzwords on a resume, so you're not aware of that
from reading my resumes.
> and once you've done that part -- Indians and Chinese can and will
I'd be glad to design the software, farm it out to I&C, then check what
comes back to make sure it does the job that was required. Do you know
any such software-design jobs available now? I've never seen any such
jobs advertised anywhere, ever in all the years since I started
programming.
|
| Author |
Message |
Jerry Gaspard

|
Posted: 2005-10-9 12:28:00 |
Top |
java-programmer, Changing Tomcat configuration
Hello everyone having a slight issue with the java.home variable for
tomcat. It is pointing at the JRE instead of the JDK and I have no idea
where it is set at. If anyone knows where I can change it please inform me.
Thanks,
Jerry
|
| |
|
| |
 |
Dave Glasser

|
Posted: 2005-10-9 13:12:00 |
Top |
java-programmer >> Changing Tomcat configuration
Jerry Gaspard <email***@***.com> wrote on Sun, 09 Oct 2005
04:28:26 GMT in comp.lang.java.help:
>Hello everyone having a slight issue with the java.home variable for
>tomcat. It is pointing at the JRE instead of the JDK and I have no idea
>where it is set at. If anyone knows where I can change it please inform me.
I think the java.home system property is set by the JVM itself, not
Tomcat. You need to change the setting for which JVM it uses. If
you're running it as a Windows service, right-click the system tray
icon, choose "Configure..." and then the Java tab and you should see
the place to set it. (This is for Tomcat 5.5.9). I think you can also
do this through the registry.
If you're launching Tomcat with a batch file or a shell script, you'll
have to dig through that script to find out how to change the JVM that
gets launched.
--
Check out QueryForm, a free, open source, Java/Swing-based
front end for relational databases.
http://qform.sourceforge.net
If you're a musician, check out RPitch Relative Pitch
Ear Training Software.
http://rpitch.sourceforge.net
|
| |
|
| |
 |
Roedy Green

|
Posted: 2005-10-9 15:06:00 |
Top |
java-programmer >> Changing Tomcat configuration
On Sun, 09 Oct 2005 04:28:26 GMT, Jerry Gaspard
<email***@***.com> wrote or quoted :
>Hello everyone having a slight issue with the java.home variable for
>tomcat. It is pointing at the JRE instead of the JDK and I have no idea
>where it is set at. If anyone knows where I can change it please inform me.
see http://mindprod.com/jgloss/environment.html
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
|
| |
|
| |
 |
HalcyonWild

|
Posted: 2005-10-11 0:13:00 |
Top |
java-programmer >> Changing Tomcat configuration
Jerry Gaspard wrote:
> Hello everyone having a slight issue with the java.home variable for
> tomcat. It is pointing at the JRE instead of the JDK and I have no idea
> where it is set at. If anyone knows where I can change it please inform me.
If you are using Unix/LInux, check your bash_profile or .profile shell
script. If it is calling any other user defined shell script, check
that too. Check for export JAVA_HOME="whatever", or setenv JAVA_HOME.
See what it is setting java_home to.
Note that weblogic 7 needs a different jdk. ie 1.3 while weblogic 8
needs another version, jdk1.4.x.
Tomcat 5 needs jdk1.4.x while tomcat 5.5 needs jdk1.5
Which version of tomcat are you using, under which OS. For windows,
read David Glassers post.
|
| |
|
| |
 |
| |
 |
Index ‹ java-programmer |
- Next
- 1
- pornn piictures!
contentt!
http://thecowboyfft.com
--
To UNSUBSCRIBE, email to email***@***.com
with a subject of "unsubscribe". Trouble? Contact email***@***.com
- 2
- Window refreshingHi everybody,
I have a problem with window refreshing.
When a button in a frame is pressed, a thread "SQLThread" is started
and computes for a long time. During this processing period I want to
see all the components in the frame (combobox, buttons, textarea)
instead of the blank grey frame!
I also added Thread.yield() in the "SQLThread" class, but without
success.
What else should I try?
Thanks in advance!
- 3
- static reference in a non-static methodI'm trying to run a simple program that read info from a file and
displays it on the screen. However, I am constantly getting the
following error.
==================================================================================
Exception in thread "main" java.lang.Error: Unresolved compilation
problems:
Cannot make a static reference to the non-static field tokenizer
Cannot make a static reference to the non-static field tokenizer
==================================================================================
I don't want to declare any variables static since I don't think I
need to. My code is given below.
================================================================
File myFile = new File("Info.txt");
Scanner tokenizer = new Scanner(myFile);
String str = null;
public static void main(String[] args)
{
while (tokenizer.hasNextLine())
{
System.out.println(tokenizer.next());
}
}
=========================================================================
I was getting a similar error when I was trying to read in standard
input from the user i.e. using input stream reader and buffer
reader.
Can anyone please help?
- 4
- Is this a ZipInputStream Bug?
I just got thru tracking down what was happening, but I still don't know
WHY.
Im using ZipInput & Output Stream classes to make a compressed file
(actually it's an image). I create it via ZipOutputStream using a 1K
buffer for writing i.e.:
...
try { // Create the ZIP file
zos = new ZipOutputStream(new FileOutputStream(zipfname)); }
catch (IOException e) {
System.out.println("ZipOutputStream error on open.");
return null; }
try { zos.putNextEntry(new ZipEntry(imgfname)); }
catch (IOException e) {
System.out.println("ZipOutputStream error on put-entry.");
return null; }
...
try { zos.write(bbuf, 0, bix); }
catch(IOException e) {
System.out.println("ZipOutputStream error on write.");
error = true;
break;
}
...
Here bbuf is 1K.
All is ok - WinZip can extract it and the image is fine. Then I try to
read it back via ZipInputStream - i.e.:
...
try { zis = new ZipInputStream(new FileInputStream(filespec)); }
catch (IOException e) {
System.out.println("ZipInputStream error on open.");
return pixels; }
try { zent = zis.getNextEntry(); }
catch (IOException e) {
System.out.println("ZipInputStream error on get-entry.");
return pixels; }
...
while ( cnt > 0 ) {
try { rcnt = zis.read(bbuf, rcnt, cnt); }
catch(IOException ex) {
System.out.println("ex: " +ex.getMessage());
error = true; }
cnt -= rcnt;
}
...
Here is where the problem occurs. If bbuf is 128 or 256 bytes the image
returns just like it should. But if I increase it to 1K junk starts to
show up within the picture at 4K the picture is barely viewable because
of the junk and at 32K I get ArrayOutOfBounds exception during the read
(NOT related to my code). I've verified that the "junk" is data that did
not come out of the zip, the way it went in.
I'm running JDK 1.3.1 on an NT4.0 platform.
Have others seen this behavior ?
Any ideas on why ?
TIA
Don Sykes
- 5
- Exiting a class in the middleI am working on a multi-threaded server-socket application. I already
have lots of crazy loops which are needed in order to function
properly.
What I need to add is a function that once all the people logged-on
exited, the server would be ready to accept connections again.
IS THERE A COMMAND THAT WOULD BREAK THROUGH THE CLASS AND EXIT IT
ANYWHERE TO GO BACK TO THE CLASS, WHICH CALLED IT (IN MY CASE BACK TO
MAIN).
I tried Label:
continue Label;
but I really do have messy loops that won't let this work properly.
I also thought maybe "System.exit(1);" would work, but that terminates
the whole application.
Any suggestions would be very appreciated.
Little BrainC
- 6
- instanceof strange behaviourHi there.
I have a problem that consists of the following.
In my class, I have a method named getNativePreparedStatement that
receives a parameter of the type PreparedStatement:
private PreparedStatement getNativePreparedStatement(PreparedStatement
ps)
I pass to this method a non null object of the type:
org.apache.commons.dbcp.DelegatingPreparedStatement
Inside this method, I do a conditional instruction like this:
if(ps instanceof DelegatingPreparedStatement){
//some code here
}
What happens is that in the if instruction the instanceof operator does
not recognize the object ps as a DelegatingPreparedStatement object.
Now, I am sure ps is of the type DelegatingPreparedStatement.
Does anyone have some clue why this happens?
I am running this application under the Apache Tomcat application
server and I am using struts.
Regards,
LA
- 7
- java and XMLHi
I have the following bit of Java code:
//Use JTidy implementation to create an empty Document object
Document doc = tidy.createEmptyDocument();
//bodyElement is the body element in an HTML Document
Node first = bodyElement.getFirstChild();
Node top = doc.getDocumentElement();
top.appendChild(first);
which produces unexpected results. Basically, all I am trying to do is
retrieve the first child node contained in the body element and copy it to
the new document element. But what I get is the required element AND every
element after it - every one of the first elements siblings! I have tried so
many variations of the above, using DocumentFragments etc, but with no joy.
In order to preserve the little hair I have left, I would be grateful for
any help
Tony
- 8
- mvn - deploying problemHi!
I use maven to develop software and recently encounter a problem
deploying a generated project site.
I am using scp protocol (no external scp/ssh programs) for deploying
but when I invoke "mvn site:deploy"
it prompts me to accept a host's key:
> RSA key fingerprint is b4:a2:e7:8a:44:13:16:af:0a:c6:9d:c9:20:d5:32:91.
> Are you sure you want to continue connecting? (yes/no):
The problem is that although I can accept the key each time I am
deploying the project site from my local workstation, it can't be
automatically deployed by continuous integration software
(CruiseControl to be
more specific). I get this error from mvn running on the remote
machine:
> Embedded error: Cannot connect. Reason: reject HostKey: cruise.veraxsystems.pl
And my question - is there any way to force maven-site-deploy to
accept the host's key without confirmation?
The ideal solution would be adding the key to settings.xml in
<repository/> section so the deploy plugin
will not be asking for it - I wonder if this is possible.
(I have already tried to run mvn in non-interactive mode using "-b"
command line switch but this produces
the same error).
Any help appreciated.
Thanks in advance
Artur
- 9
- sysdeo plugin for tomcat/eclipse gone?Hello,
does anybody still have a copy of the latest pluging of sysdeo for
tomcat/eclipse integration? The link to
http://www.sysdeo.com/eclipse/tomcatPlugin.html
does not work anymore...
And I really liked this integration.
Thanks for hints.
- 10
- programming the JVMHi,
I'm wanting to program the JVM independant of a compiler by
emitting bytecodes directly and I have orderd the book by J Engel
'Programming for the JVM'.
The lead on this book from amazon is 4-6 weeks which (may?) turn
into never. Does anyone here have recommendations for alternate
texts (that are introductory/tutorial in nature, rather than
reference texts) and websites that may help me with this - so
I don't just sit kicking my heels while it possibly doesn't arrive?
I've hunted in most of the obvious places but nothing seems to
fit the need or cover the topics that the Engel book does
sensibly.
TIA
Chris
- 11
- Doctors Use This Too SSBfa5
"Ci-ialis Softabs" is better than Pfizer Viiagrra
and normal Ci-ialis because:
- Guaaraantees 36 hours lasting
- Safe to take, no side effects at all
- Boost and increase se-xual performance
- Haarder e-rectiions and quick recharge
- Proven and certified by experts and doctors
- only $3.99 per tabs
Cllick heree:
http://ossifies.com/cs/?ronn
o-ut of mai-lling lisst:
http://ossifies.com/rm.php?ronn
eD
--
To UNSUBSCRIBE, email to email***@***.com
with a subject of "unsubscribe". Trouble? Contact email***@***.com
- 12
- AXIS attachment problemHi,
Currently i tried to make attachment with AXIS .
I have following error message
Exception in thread "main" AxisFault
faultCode: {http://xml.apache.org/axis/}Server.NoService
faultSubcode:
faultString: The AXIS engine could not find a target service to invoke! target
Service is null
faultActor:
faultNode:
faultDetail:
I think i could resolve my problem if i found a little attachment sample ?
Where could i found it, or a tutorial ?
Regards
Philippe
- 13
- Need some assistance pleaseHello everyone! I am trying to learn java and have run into kind of a
snag. Here is the code that I have so far:
------ <begin_code> ----------
import javax.swing.*;
import javax.swing.JApplet;
import javax.swing.JOptionPane;
import java.awt.Graphics;
public class Rectangles {
public static void main ( String args[] ) {
// Variables to hold the users input
String number1;
String number2;
String number3;
String number4;
int x;
int y;
int width;
int height;
nextRect: // Continue point for drawing another Rectangle
// Gather input and parse into integers
number1 = JOptionPane.showInputDialog(null, "Please input the x value: ");
number2 = JOptionPane.showInputDialog(null, "Please input the y value: ");
number3 = JOptionPane.showInputDialog(null, "Please input the width
value: ");
number4 = JOptionPane.showInputDialog(null, "Please input the height
value: ");
x = Integer.parseInt(number1);
y = Integer.parseInt(number2);
width = Integer.parseInt(number3);
height = Integer.parseInt(number4);
public void paint( Graphics g )
{
super.paint(g);
g.drawRect(x, y, width, height);
String answer;
answer = JOptionPane.showInputDialog(null, "Would you like to draw
another rectangle? ");
if ( answer == "yes | y")
continue nextRec; // go to nextRec and start over
else
System.exit(0);
}
}
}
------ </end_code> --------
Now, the problem I am having, is I am getting an error between the 't' and
the '(' in "public void paint( Graphics g )" Please be kind in your
comments and keep in mind that I am just learning. If I am trying to do
something that I shouldn't please let me know. I would really like to
know why this won't work.
Thank you in advance!
Regards,
jlk
- 14
- Dice Frequency SimulationHi I'm new to JAVA Programming and need help with my homework!
The assignment: Design and implement a simple, well-documented JAVA
program that uses random numbers to simulate throwing a pair of dice
and recording the total score thrown. That is, each roll will throw
two dice, each of which can randomly result in a face up value of 1,
2, 3, 4, 5, or 6. The program should add the two values to get a
score for the roll. The score will be between 2(1+1) and 12(6+6).
The program should loop to roll the dice a total of 500 times and
should sum up how many times each score was thrown. That is, how many
of the 500 times was a total of 2 thrown, how many times was a total
of 3 thrown, etc. You will need one accumulator for each of the 11
possible scores. Afer all 500 rolls have been thrown and counted, the
program should report for each possible score (2-12), how many times
it was thrown and what % of the time it was thrown. This program
will have no input. It should produce output similar to the
following:
Total Number Percent
Rolled of Times of Time
So far, I know to use the for loop with the following values: (count =
2; count <= 500; count++) but then I'm stuck. I don't know what to do
next!!
- 15
- JGoodies JLabel with multiple linesHi
I use JGoodies Forms to create a GUI application. I need to show a simple
multiline description in the window. I use JLabel with html text like
"<HTML> ... my description ... </HTML>".
Because it's multiline, java never knows how much lines it contains and what
is initial height of that component. When I add this do panel and show on
the screen, my frame has to small height and hides some components. General
problem is that I use different fonts (almst blind user can select bigger
fonts).
code:
-------------------------------
FormLayout layout = new FormLayout("fill:500px", // kolumny
"p, 10px, p, 10px, p, 7px, p, 7px, p, 10px, p"); //
wiersze
PanelBuilder builder = new PanelBuilder(layout);
builder.setDefaultDialogBorder();
CellConstraints cc = new CellConstraints();
...........
builder.add(textArea, cc.xy(1,3));
...........
getContentPane().add(builder.getPanel());
pack();
Can anyone help me ?
Tom
|
|
|