java

is there any wayout to set init parameter in servletconfig or servletContext object?

if i want to modify init-parameter value in any of ServletContext or ServletConfig. any want it to be updated after servlet is destroyed by container. is there any wayout? ...

Is there something like java's Character.digit(char ch, int radix) in c#?

Character.digit(char ch, int radix) Returns the numeric value of the character ch in the specified radix. Is there an equivalent function in c#? ...

Creating website

Hi, I want to create a website over banking. I just wanna know what's more do I have to know to create website. Is the knowledge of servlet, JSP, HTML, CSS is enough to make a website? Or do I have to know Javascript as well? Thanks in advance. ...

Making a J2ME Midlet sleep without threads?

Hi All .... Quick question ... Using J2ME (CLDC 1.1, MIDP-2.1) is it possible to sleep the Midlet for a period of time (not using threads)... For example: public class myMidlet extends MIDlet{ public void startApp() { /* Sleep for 10 seconds */ /* The answer was: */ try { Thread.sleep(time_ms); ...

How can I build a compile graph for Java files?

I have a large number of classes in a project, and I would like to compile all of them from a script. The thing is, the classes should be compiled in a certain order, for example: I have a class named A which depends on a class named B. Let's say class B depends on a class named C. In order for me to compile class A, I would have to comp...

Can I dynamically load additional Spring configuration files into an existing WebApplicationContext?

Upon starting my webapp within Tomcat 6.0.18, I bootstrap Spring with only what is necessary to initialize the system -- namely, for now, database migrations. I do not want any part of the system to load until the migrations have successfully completed. This prevents the other beans from having to wait on the migrations to complete bef...

Using Statement.RETURN_GENERATED_KEYS with MS-Access JDBC-ODBC throws exception

import java.sql.* ; import java.util.* ; import java.io.* ; class DataBaseFactory{ public static Connection getConnection() { // ... } } class Demo{ public static void main(String []args) throws SQLException { Connection con = DataBaseFactory.getConnection() ; // This is throwing exception /...

Text area text to be split with conditions

I have a text area where a user can enter free flow text. I want to separate out lines/occurrences in my Java class based on the below conditions: When the user does not press the enter key, I want to get substrings (texts) of 10 characters each. When the user does press enter, I want to separate that part out and start again counting t...

Shortest code to start embedded Jetty server

I'm writing some example code where an embedded Jetty server is started. The server must load exactly one servlet, send all requests to the servlet and listen on localhost:80 My code so far: static void startJetty() { try { Server server = new Server(); Connector con = new SelectChannelConnector(); ...

Selector doesn't block after a wakeup() on windows

I'm referring to that: on Windows my selector, after a wakeup(), doesn't block anymore and then hogs my cpu time. This is for an end-course project, where it is only required to work in our linux network, so in theory I can just ignore the problem and live an happy life, but I want to fix it anyway. Anyone could suggest me a workaround...

Wrapper for multiple FTP III party support

I am building a wrapper for FTP (File Transfer Protocol) in order to support multiple FTP III party API for FTP. The intention of writing this wrapper is to facilitate the user to select and configure any III party FTP API through some configuration file and use it through the wrapper. I have written code for the same and wondering if th...

Efficient extraction of file from jar

I have an application written in Java that uses a jar file(it uses more than one, but that's not the point). The fact is, the Jar file I'm using contains files that I absolutely MUST extract to the filesystem. So far I'm using Class.getResourceAsStream and FileOutputStream, but this method is somewhat slow. Note that some of these file...

Sorting arrays in Java

I want to pass 2 arrays to a function in Java and have them sorted in the calling function. How do i use a function to accomplish that? I could have the function return an object with 2 arrays, but is there a non object-oriented solution to this? EDIT : I this particular situation I cant use the inbuilt Array.sort function in Java. ...

How can I split a given String using either + or -?

I want to split a polynomial like: 2x^7+x^2+3x-9 Into each one of its terms (2x^7, x^2, 3x, 9) I've thought about using String.split(), but how can I make it take more than one paramether? ...

GWT application/eclipse plugin crashes JVM

I'm trying to set up the GWT framework. I'm following the quick start at: http://code.google.com/eclipse/docs/getting_started.html. OS is Ubuntu 8.04. I create a new application and start/debug the application, and after a few seconds JVM crashes. Any ideas? Generated log is: # # An unexpected error has been detected by Java Runtime Env...

Hibernate ordering

I have the Vehicles class and mapping file for it and i want to get all rows from vehicles table ordered by ID desc (I also need the same for my other tables). I got the following code: session = HibernateUtil.getSessionFactory().getCurrentSession(); tx = session.beginTransaction(); q = session.createQuery("from Vehicles order by ID D...

GWT DecoratedTabPanel tab button color

how can I change the color of a tab in a DecoratedTabPanel? I don't mean the content but the button you click on to select a tab. ...

maven compile groovy

I have a situation where some of my groovy code references my java files, but I also have different java files that reference the same groovy code. When trying to compile in maven, I either need to compile the groovy before or after the java, and that won't really work since the groovy code depends on some java files, and different java ...

MySql in WinXP and Mac OS X

Hello Folks, I am facing this bizarre problem. I am coding on my machine in Win XP and then moving all the code to Mac OS X machine. Running it using the jars from XP machine. I am coding in java and using hibernate for database processing. Somehow I am not able to insert one row, while the keys are generated using the increment ge...

garbage collection of an object that holds reference to alive threads

In Java: I have an object that holds references to 2 daemon threads. I am considering the corner case where it is not deinitialized, so I can determine whether I need a finalizer. The function for detinitializing stops the threads. I could go ahead and just add a finalizer but I am curious: a) Can the object get garbage collected while...