java

Definitions of "primitive", "value type", "struct", "class", "wrap" in Java and C#

I have been trying to understand the use of "primitives" in Java and C# and the difference between them (if any). I have asked a series of questions on SO and some of the answers seem to confuse the issue rather than clarify it. Some answers (and some MS documentation) appear to provide contradictory statements. From SO http://stackove...

Java - getting the signature of a method in an interface, and the same for its Proxy implementation

I'm looking for a way to extract the essence of a signature in Java. The reason is that I want to use the signature as a unique key in a Map for my java.lang.reflect.Proxies. With this code: public interface MyInterface { public int compute(String s); } ... public static void main (String... args) throws Exception { InvocationHand...

java web: how to redirect stacktrace of uncaught exception to a log file?

I want to redirect only stacktrace of uncaught exception from console to log file. The rest of the things should appear on console as usual. ...

Cookie available in the same request/response

Hi All, I have found a strange behaviour (strange for me, a novice :D) in my project. Basicly after an action I create or update a cookie (if it exists or not) and send it to the client. The strange thing is that in the jsp I can read the cookie ONLY when I update its value (and I get the updated value, not the old one) but not the fir...

Dereferencing Aliases in LDAP using Spring

How to control LDAP Alias Dereferencing Mode using Java and Spring LDAP API? Similarly to how it is done using ldapsearch on linux. Example: ldapsearch -a never "(&(o=foo)(cn=bar))" cn ldapsearch -a always "(&(o=foo)(cn=bar))" cn ...

BlazeDS and ColdFusion - jRun memory usage increase resulting in java.lang.OutOfMemoryError: Java heap space

I have BlazeDS running in an instance of Coldfusion 8. A flex chat app that acts as both a producer and consumer with 70 long polling requests allowed, moving to client polling with a polling interval of 2 seconds. jRun metrics logging is enabled. The server is set up with a max heap size of 1200mb, 210 max jrun threads and 150 max simul...

Problem viewing textfields in java applet

Hello all, Extremely new to Java an just playing around with it. I'm trying to add text fields to below a table and for some reason I can't see them. Code is below: import java.applet.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; public class danTeamProject extends JApplet implements ActionListener { danTable a...

Multiple pages in portlet

Hello everyone, i'm facing the following problem, there are two pages (views) in my portlet, first with rich:tree of components and the second with create/edit form for this components. On the first page i have the following code: <s:link value="#{treeitem.name}" view="/view/testSet/testSetCreation.xhtml"> <a4j:support event="oncl...

Is it bad to use servicelocation instead of constructor injection to avoid writing loads of factory classes

Right now we use DI/IOC and when we need to pass extra parameters to a constructor we use a factory class e.g. public class EmailSender { internal EmailSender(string toEmail, string subject,String body, ILogger emailLogger) {.....} } public class EmailSenderFactory { ILogger emailLogger; public EmailSenderFactory(ILog...

Learning more about Java

Hi I would like to become really good at programming and in particular java and OO The catch is, that while I like programming and I work as a programmer, I'm not really passionate about being a programmer or programming in general. This leads to not feeling like doing any dev outside of work, which means that I rarely learn anything ...

How can I wrap a Java enum and still iterate over it?

How can I have an abstract enum, or some kind of base enum? In my common code I'd like a notion of an enum placeholder, MyItems, without tying myself to a concrete enum. Then in each of my projects I would have a concrete implementation. E.g. Common Code public interface MyItems { // Marker interface } Project A public enum I...

Quartz Scheduler and thread pooling

Please provide me some samples on Quartz Scheduler and thread pooling ...

Problem while copying JTable contents into Excel

I have a Standalone application in which I am trying to copy contents of JTable into Excel with line breaks included in my cells of JTable. I have used wrapping using "\"" to my cell contents. It's working fine but I am getting a square box type of symbol in place of line breaks in Excel. How to remove the symbol while copying? Is there ...

How to read pixel color in a java BufferedImage with transparency

Hi, I am reading pixel color in a BufferedImage as follows: ..... InputStream is = new BufferedInputStream(conn.getInputStream()); BufferedImage image = ImageIO.read(is); int color = image.getGRB(x, y); int red = (colour & 0x00ff0000) >> 16; int green = (colour & 0x0000ff00) >> 8; int blue = colour & 0x000000ff; Now this works f...

Decoding split 16-bit character in Java

In my application, I receive a URL-UTF8 encoded string of characters, which is split up by the sending client. After splitting, each message part includes some header information which is meant to be used to reconstruct the message. With English characters, it's pretty straightforward String content = new String(request.getParameter("c...

what is root cause of exception "org.apache.jasper.runtime.PageContextImpl.handlePageException"?

Exception log javax.servlet.ServletException at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:536) at org.apache.jsp.FileUploadFormatAdd_jsp._jspService(FileUploadFormatAdd_jsp.java:620) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137) at javax.servlet.http.HttpServlet.service(...

Making sure String does not exceeds 2000 bytes in Oracle database table column

Want to truncate error string so it for sure fits into Oracle table column VARCHAR2(2000 BYTE) Design forces: The main goal is to fit to the table column. 90-95% of string text is exception message and stacktraces. But it could contain some customer name with french, turkish characters which I am willing to disregard and see as ? or ...

Natural Language Processing in C++

I'm working on a project that already has a C++ base. I would like to have a plug-in for some natural language processing. I really like GATE but I'm not sure if it's worth launching the JVM and splitting the project into C++ and Java portions. I noticed UIMA has a C++ framework, but have not tried it but seems to have less features t...

Implementing result paging in hibernate (getting total number of rows)

How do I implement paging in Hibernate? The Query objects has methods called setMaxResults and setFirstResult which are certainly helpful. But where can I get the total number of results, so that I can show link to last page of results, and print things such as results 200 to 250 of xxx? ...

Stream-lined xml builder/parser in Android?

I'm learning the Android api from a book, and it seems like there isn't any mention of a stream-lined api for dealing with raw xml (reading and writing). His suggestion for parsing is the XmlPullParser, and his examples look horrendous considering the kind of api's I'm spoiled by in other platforms (LINQ to XML especially). Is this the...