java

Free Native Launcher For Java At Linux and Mac

My Java application require a huge memory heap. I need to launch my application using java -Xms32m -Xmx128m xyz.jar Hence, I would like to create native launcher for my Java application, where I can pass the JVM heap size parameters in. I plan to use JSmooth http://jsmooth.sourceforge.net/ for Windows platform. However, I would also l...

PowerBuilder for a Java programmer?

A friend of mine uses in his company an ERP software written in PowerBuilder. Unfortunately the (one and only) developer is going into retirement soon. My friend really likes the software and wants to keep using it for at least ten more years, so my friend decided to buy the source code. He wants to start a business to maintain the soft...

Get file name from URL

In Java, given a java.net.URL or a String in the form of http://www.example.com/some/path/to/a/file.xml , what is the easiest way to get the file name, minus the extension? So, in this example, I'm looking for something that returns "file". I can think of several ways to do this, but I'm looking for something that's easy to read and sh...

How can multiple webapps in the same tomcat instance share database connection pool?

Having in mind that each webapp has its own separate database (but all databases are in the same database server). The scenario is that I have a multi-tenant saas application - I deploy the same application for each customer. Each customer works on a database that is called db_cid, where cid is the customer id, i.e. a a unique customer ...

Does it matter what I choose for serialVersionUID when extending Serializable classes in Java?

I'm extending a class (ArrayBlockingQueue) that implements the Serializable interface. Sun's documentation (and my IDE) advises me that I should set this value in order to prevent mischief: However, it is strongly recommended that all serializable classes explicitly declare serialVersionUID values, since the default serialVersionUID ...

Is it possible to remove the "Class<T>" parameter from this Java method?

I have a Java method with the following signature: public <T> List<HtmlOptionsComposite> convertToHtmlOptionsCompositeList (List<? extends T> objects, Class<T> clazz, String getValueMethodName, String getDescriptionMethodName, String getDiscontinuedMethodName) { ... } The clazz parameter is required by the ...

Proxool maximum connection count

I'm using proxool java connection pool (version 0.9.1). Everything works fine till I reach the maximum connection count. If the maximum connection count is reached proxool immediately throws an SQLExcepion: java.sql.SQLException: Couldn't get connection because we are at maximum connection count (n/n) and there are none available Of ...

Sort a single String in Java

Is there a native way to sort a String by its contents in java? E.g. String s = "edcba" -> "abcde" ...

Legacy mapping with hibernate

For my current project I have to map a legacy database using hibernate, but I'm running into some problems. The database is setup using one 'entity' table, which contains common properties for all domain objects. Properties include (among others) creation date, owner (user), and a primary key which is subsequently used in the tables for ...

Where should I put the SQL files in my Java project?

I have a Java project which will include a number of large SQL statements for querying the database. My question is: where should I store them? I'm fairly sure I want each statement its own text file managed by source code control. As Java doesn't support multi-line strings I can't easily put the SQL in my .java files and I don't thi...

Implementation of X-modem protocol in Java

I want to receive a file from serial port and I have to use that X-modem protocol is designed to receive a file over serial port in Java. So if anyone can have idea about then plz help me. I am in very much trouble.plz ...

How do you clear the Java Console?

I have output messages displayed on the Java console for an application that started using webstart. Instead of the user manually clearing message, is there a way of clearing console messages in code? These messages are printed at the rate of about 1000 per second and seem to end up using too much memory, i could have stopped the printi...

JibX: how to output the fields from a particular class into different parts of the XML

I've managed to get what I want when mapping with inheritance like this: ThisClassShouldntExist freeFlowMsg errorMsg BaseForm extends ThisClassShouldntExist function subFunction SpecificForm extends BaseForm address My binding.xml: <binding> <mapping class="com.struts.form.ThisClassShouldntExist" abstract="true"> <...

Static variables and methods

I ran across a class that was set up like this: public class MyClass { private static boolean started = false; private MyClass(){ } public static void doSomething(){ if(started){ return; } started = true; //code below that is only supposed to run //run if not started } } My understanding with sta...

replace a set of characters with another set of chars (in pair): "&", "&amp;" "<", "<" etc. in regex

I have to encode the 5 XML reserved chars (& < > " and ') properly as follows: "&", "&amp;" "<", "&lt;" ">", "&gt;" "\"", "&quot;" "\'", "&apos;" I can do them one by one, but is it possible in regexp something like ("[&|<|>|\"|\']", "&|<"); ... etc so that it will not be executed in 5 operations one after another but alltogether s...

Java mock webserver

I would like to create a unit test using a mock web server. Is there a web server written in java which can be easily started and stopped from a junit test case? ...

Gridview like display for hibernate objects in Java?

Essentially what I am looking for is a good way to build a quick database interface. In my (limited) experience with ASP.net I've used a Gridview control for this task. However for this project I am going to be using Java. Can anyone recommend a good way to set up a Gridview like control (with editable and sortable rows) in a Java web f...

Generating and Displaying PDF file in Flex/Java

We have Flex on the front end and Java on the back end. When a user will request for a PDF file, request will go to the Java backend, where a PDF file will be generated using Jasper Reports. What we dont know is how to display this PDF file in browser; since we dont want to use JSP/Servlets etc - It has to be flex only. Any suggestions? ...

Is there a way to make a JComboBox act like an HTML Select?

What I am trying to do mimic an HTML Select tag. I want to display text as an option but when selected, I would use its value. For example, I would have a list of country names. However, when a user selects Japan, I want to get the Locale Code for that country. So the user sees that they selected Japan, but my code will get "ja_JP" or s...

Highlight inherited members

Is there a way to visually separate an inherited class member, i.e. a variable that is defined public/protected in a superclass? I noticed that it's possible to stylize abstract members separately... I'm using Eclipse Ganymede. ...