java

paging through a very large text file

I need to implement a paging widget that would be able to read an arbitrarily large text file. widget will be used by different apps with a wide range of hardware (mobile with low ram on low end) so need to be fairly memory stingy and efficient. the amount to be paged is also going to be arbitrarily different for each user. is there any ...

How to use JPA to connect to Derby

A related query I asked: http://stackoverflow.com/questions/1892089/how-to-configure-package-a-simple-java-app-to-uss-jpa I have a simple Derby database which I can connect to via EJBs hosted in WebLogic. Now I would like to connect to it from a command line Java app using JPA. So far this Java code + persistence.xml file is throwing...

Io exception: There is no process to read data written to a pipe.

I'm using Hibernate3.2+Websphere6.0+struts1.3.. After deploying ,application works fine. After some idle time ,i will get this type of error repeatedly,am not able to login at all. Im not using any connection pooling. i feel after idle time its not able to connect to the database again..if i restart the server everything works fine for ...

How to start a career in Java? Java SCJP Certificate?

Hi Stackoverflowers! I am planning to write the SCJP exam soon, and I wonder if that will be helpful to get Graduate/Junior Java Programmer job. Exam seems to be easy to pass for some people. What is the minimum scope of knowledge to start thinking about career in Java field? Do you think that SCJP will be enough to dive in to Java wo...

Is regex in Java anchored by default with both a ^ and $ character?

From my understanding of regular expressions string "00###" has to match with "[0-9]", but not to "^[0-9]$". But it doesn't work with Java regexp's. After some investigating of this problem I founded next information (http://www.wellho.net/solutions/java-regular-expressions-in-java.html): It might appear that Java regular expressi...

Eclipse on windows doesnt start

I usually do all my java development on linux, using fedora package manager setting up a development environment is easy and fast. Now I have to start using windows but I never used it for java development and im having a few difficulties having it setup. So I downloaded and installed thye java 6 JDK (just the standard edition, not the...

Java's ReadableByteChannelImpl inconsistent behaviour

When I create a channel out of the InputStream with Channels.newChannel(is) java standard library returns a ReadableByteChannelImpl, which is: private static class ReadableByteChannelImpl extends AbstractInterruptibleChannel // Not really interruptible implements ReadableByteChannel { InputStream in; ...

Any solution for Class.getMethod() reflection and autoboxing?

I want to use Class.getMethod(String name, Class... parameterTypes) to find the method I need to invoke with the given parameters, but apparently as described in Bug 6176992 Java doesn't include autoboxing there. So if my reflected class has a method with a (String, int) signature you still get a NoSuchMethodException with a {String.c...

What is the difference between object-oriented langauges and non object-oriented languages?

I am new to programing and I have been hearing a lot about how C is a non-object-oriented language and how java is an object-oriented language I was wondering what the difference was? Thank you. ...

Using VTK 5.4.2 with Java in OS X 10.6

Has anybody successfully ran any Java code using VTK 5.4.2 under OS X? I've installed VTK 5.4.2 from source, configured for Java and shared libraries. The vtk.jar file is generated as expected, and the Java program compiles correctly. However, when executing, as soon as the wrapper classes call the underlying *.dylib libraries, it appe...

Adding a Web Browser in a JFrame/JPanel/JComponent in Java

I'm doing a Java application that requires to use a web browser inside the application. I have seen some applications doing this, such as RSS readers when clicking in a feed in the left panel and opening the link in a right panel in the same application, and I would like to implement something similar. Is it possible to do this in java...

Histogram frequency help Java

public class Histogram { private int lo_; private int hi_; private int[] frequency_; public Histogram(int lo, int hi) { lo_ = lo; hi_ = hi; int range = hi_-lo_+1; frequency_ = new int[range]; for(int i =0; i <range; range++) frequency_[i] = 0; } public void ReadValue() { Scanner in = new Scanner(System.i...

Porting C code; need help with bitwise operation and pointer syntax

I have some C code that I'd like to port to java. I haven't done much C coding, but I was able to follow along up until this one function. If anyone could help me understand what is going on, it would be greatly appreciated. int reverse_integer(int input) { int output = 0, i; for ( i=0, i<sizeof(int); i++ ) { output =...

Alternative options for displaying video in Java?

At the moment I use QuickTime for Java to display video in a swing application. However, Apple has deprecated support for QTJava and I was wondering what options other are available right now+ for moving forward? Requirements: Must be cross platform (WIN & OSX). Must be able to support many different video formats. Must be capable of ...

Scatter Graph with multiple "scatter lines"

Ok, I know about JFreeChart and others, but I'm coding my own simple scatter graph. I've already got a box chart down (without y-axis labels but that shouldn't be a huge problem when I explain it in my report). I've got a basic scatter graph class, however I've tried to change it so that I can add in different scatter values. It works,...

How to use EnumSingleValueConverter with XStream?

I am trying to serialize a List which looks as follows: public class Comp { public enum TYPE { Type1, Type2, Type3 }; public Type type; So, I create a list of these like this: Comp a = new Comp(); a.type = Type.Type1; Comp b = new Comp(); b.type = Type.Type2; List<Comp> list = new List<Comp>(); li...

Odd comparison problem in checking for anagram

I'm sorry, the title's awful; however, I couldn't think of any better way to summarize my plight. In trying to solve a problem involving checking to see if one string is an anagram of another, I implemented a solution that involved removing all whitespace from both strings, converting them both to character arrays, sorting them and then...

Java, inner classes and instanceof

Hello, I coded in NetBeans something like this: public class Grafo<V, E> { class Par { int a, b; Par(int a, int b) { this.a = a; this.b = b; } @Override public boolean equals(Object ob) { if(ob instanceof Par) { Par p = (Par)ob;...

Why would you catch InterruptedException to call Thread.currentThread.interrupt()?

In Effective Java (page 275), there is this code segment: ... for (int i = 0; i < concurrency; i++) { executor.execute(new Runnable() { public void run() { ready.countDown(); try { start.await(); action.run(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } finally { ...

Issues about unpacking files to build an Eclipse installation in support of a runtime API

I have an application that uses the Eclipse runtime. Unfortunately, due to restrictions in Equinox (the Eclispe OSGi implementation), it's not possible to start the Eclipse runtime with all of the plugins on the classpath, so it must actually be located on the disk. (There is code that insists to look for the OSGi framework bundle usin...