java

What are the deficiencies of the Java/C# type system?

Its often hear that Haskell(which I don't know) has a very interesting type system.. I'm very familiar with Java and a little with C#, and sometimes it happens that I'm fighting the type system so some design accommodates or works better in a certain way. That led me to wonder... What are the problems that occur somehow because of def...

How do I manually open a hibernate session?

I have a rather large project involving spring and hibernate. Right now, I'm backing certain objects out of hibernate and into memory, and I've hit a sort of snag. I have the following setup. Class A contains a number of primitives and a class B. B contains primitives and a class C, which was previously lazy-loaded. Now I have this ...

Better Java method Syntax? Return early or late?

Duplicate: Should a function have only one return statement? and Single return or multiple return statements? Often times you might have a method that checks numerous conditions and returns a status (lets say boolean for now). Is it better to define a flag, set it during the method, and return it at the end : boolean validate(Doma...

Database tables for entries of another table?

I'm designing a new revision of my Java application (using an embedded H2 database) around a redesign of the way I'll be handling my data. Here's how I have it planned: Entries table- Entry ID Entry name Properties table- Property ID Property name (Individual property) value table- Value ID Entry ID (Value columns...) (Individua...

rxtx com port

Hi, I am using rxtx api to read data from a GPS device over a com port. Right now I'm finding the correct com port by reading a config file and looking for the port listed. The problem that I'm having is that if the device is unplugged the com port could change then the user has to know to change the config file. I wrote an app similar t...

Setting up ehcache replication - what multicast settings do I need?

I am trying to set up ehcache replication as documented here: http://ehcache.sourceforge.net/EhcacheUserGuide.html#id.s22.2 This is on a Windows machine but will ultimately run on Solaris in production. The instructions say to set up a provider as follows: <cacheManagerPeerProviderFactory class="net.sf.ehcache.distribution.RMICac...

Utility for downloading artifacts from maven repo without mvn/poms

Is there a maven client that isn't mvn (the binary included with the maven distribution) I could use to pull down an artifact from a maven repository without using a pom? I'd like to use a maven repository as the repo for our ops team to pick up builds (including snapshots of builds) but I don't want them to have to mess around with wr...

Can Java annotation do this?

Pardon me if this is a stupid question as I'm new to Java annotation. I'm looking into a solution that displays the subversion revision number and last modification date in my application (written in GWT, therefore reflection is not available). Encode the revision in subversion keyword doesn't work as it applies only to the current file....

How do I send an e-mail in Java?

I need to send e-mails from a servlet running within Tomcat. I'll always send to the same recipient with the same subject, but with different contents. What's a simple, easy way to send an e-mail in Java? Related: How do you send email from a Java app using GMail? ...

How do I authenticate a user with the "Smart card is required for interactive logon" set?

http://support.microsoft.com/kb/892424 When the "Smart card is required for interactive logon" is set on Active Directory, it generates a random password. How do I utilize a smart card to authenticate a user over LDAP from a web application? How do I know who the user is? Is there a way to access the cert? Can I get it from the session...

Emma doesn't embed source code to html report

Hello, I have a problem with Ant and Emma a code coverage plugin, it makes report, but without source code. I got following code in my build.xml init emma <taskdef resource="emma_ant.properties" /> <path id="run.classpath"> <pathelement location="${instr}" /> <path refid="build.classpath"/> <pat...

java servlet : how to speed this up?

I have the following function which is called for every line item produced. Does anyone have any ideas how to speed this up? private String getDetails(String doc){ String table=""; java.sql.ResultSet rs = qw.DBquery("select " + "id,LineType, QtyTotal, ManufacturerPartNumber, Description, UnitCost,UnitPrice " + ...

Need a function to limit a line (known by its coordinates) in its length

Hello! I need a function which takes a line (known by its coordinates) and return a line with same angle, but limited to certain length. My code gives correct values only when the line is turned 'right' (proven only empirically, sorry). Am I missing something? public static double getAngleOfLine(int x1, int y1, int x2, int y2) { do...

Hyphens in column names in MySQL DB

May be this question has been answered before but I couldn't find it. I am using a 2/3 yr old MySQL database which has hyphens in its column names. When I try to use these names from my Java code, the names are broken at the hyphen (e.g. air_port becomes air) and thus are not found. I tried replacing hyphens to underscores in my code ho...

Narrowing problem with Spring MVC annotation-based controller and @RequestMapping

Consider this Spring MVC Controller: @Controller @RequestMapping("/test*") public class TestController { @RequestMapping(method = RequestMethod.GET) public void doStuff(Model model){ ... } @RequestMapping(params = "myParam") public void doStuff(@RequestParam("myParam") int myParam, Model model){ ... } } When I p...

Why is swallowing InterruptedException ok for subclasses of Thread ?

In Brian Goetz's article on how to handle InterruptedException, one paragraph stands out: The one time it's acceptable to swallow an interrupt is when you know the thread is about to exit. This scenario only occurs when the class calling the interruptible method is part of a Thread, not a Runnable. I don't get this. Is the reason ...

Teracotta and Hibernate Search

Does anyone have experience with using Terracotta with Hibernate Search to satisfy application Queries? If so: What magnitude of "object updates" can it handle? (How's the performance) What kind of performance do the Queries have? Is it possible to use Terracotta Hibernate Search without even having a backing Database to sat...

eclipse default jpa implentation library where to download?

In eclipse, the "default implementation library" what jars files do I need to include if I do not want to use server runtime? I'm refering to this tutorial http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse.jpt.doc.user/task_create_new_project.htm ...

Sending a Generic/Text directly on an Epson Matrix Printer through a USB using Java

Is there a way of sending directly an "ESC" coded string to an Epson Matrix Printer connected on a USB using Java. I've tried this one using the LPT1 port successfully. However, majority of our clients are now using USB cables instead of the old parellel cables. The main problem I have is how to open the particulary USB where the printer...

Get List of all non-builtin Types from WSDL?

Given a WSDL/XSD, what's the easiest way to produce a list of all simple & complex Types? (Java preferred.) i.e. <xsd:element name="ThirdPartyProductInfo" type="typens:ThirdPartyProductInfo" minOccurs="0"/> <xsd:element name="SalesRank" type="xsd:string" minOccurs="0"/> <xsd:element name="BrowseList" type="typens:BrowseNodeArray" minOc...