java

Eclipse JSP preview

Is there an Eclipse plugin or feature that allows previewing of JSP files? Ideally such a feature would be aware of Spring tags. It's a major pain to edit the JSP in Eclipse, then build and deploy to see the results. ...

Where is JConsole in Leopard

Hi, does anyone knows where JConsole is Located in MacOSX (Leopard)? ...

How to handle a closing application event in Java?

Having a console application, a server accepting several connections from clients, is it possible to have a listener or an event on a closing application? I want, in this event, tell all connected clients to gently disconnect before the application really closes itself. Any solution? Thank you! ...

Please help me get my random number generating working in Java

I am trying to make a Java implementation of the Park-Miller-Carta PRNG random number generator (maybe faster?) Below is the implementation of the Random function in ActionScript 3 from here. return (_currentSeed = (_currentSeed * 16807) % 2147483647) / 0x7FFFFFFF + 0.0000000002...

Understanding Goetz's article on Thread safety of HttpSession

Referring to Goetz's article, I want to refer to this piece of code HttpSession session = request.getSession(true); ShoppingCart cart = (ShoppingCart)session.getAttribute("shoppingCart"); if (cart == null) { cart = new ShoppingCart(...); session.setAttribute("shoppingCart", cart); } doSomethingWith(cart); From my avail...

How can I print a single JPanel's contents?

I have a JPanel with two labels with pictures. I need to print these content of the JPanel. Please help me out. How can I print only this JPanel's contents, as I also have different components on my JFrame but I just need to print this JPanel. Thanks. ...

Java Generator for Poisson and Uniform Distributions?

From what I understand, the standard generator is for the Normal Distribution. I have to generate random numbers according to the Normal, Uniform and Poisson Distributions, but I can't seem to find a class for the last 2. I have to generate them in the range of 0 - 999999. ...

Java XML APIs

I've dealt with a few XML APIs in Java, but I don't have a good understanding of all the frameworks available in Java for dealing with XML for whatever purpose (e.g. JAXB, JAXP, Xerces, StAX, Castor, etc.). Can anyone highlight the most popular Java XML APIs and give a quick description of what they're intended to be used for? I'd also...

Java programming in SWT

HI.. i have this piece of code in java... import org.eclipse.swt.SWT; import org.eclipse.swt.custom.CTabFolder; import org.eclipse.swt.custom.CTabItem; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.RowLayout; import or...

How to know whether a file copying is 'in progress'/complete in java (1.6)

I am writing a directory monitoring utility in java(1.6) using polling at certain intervals using lastModified long value as the indication of change. I found that when my polling interval is small (seconds) and the copied file is big then the change event is fired before the actual completion of file copying. I would like to know wheth...

How does getWriter() function in an HttpServletResponse?

In the method service(), we use PrintWriter out = res.getWriter(); Please tell me how it returns the PrintWriter class object, and then makes a connection to the Browser and sends the data to the Browser. ...

StringTokenizer - first string?

I have this code to parse url string such as "?var=val" but when "search" is just "var=val" this code fails, how to make just "var=val" work as well? StringTokenizer st1 = new StringTokenizer(search, "?&;"); while(st1.hasMoreTokens()){ String st2= st1.nextToken(); int ii = st2.indexOf("="); if (ii > ...

JTextArea with strange behaviour when resizing the JFrame

Hi. I'm using some JTextArea in my Swing application. The surrounded JScrollPane is added to a JPanel using the GridBagLayout manager. // Pseudo Code ---- JTextArea area = new JTextArea(); area.setRows(3); JScrollPane sp = new JScrollPane(area); JPanel p = new JPanel(new GridBagLayout()); p.add(sp, new GridBagConstraints( ...

How to request JVM garbage collection (not from code) when run from Windows command-line

Hi. how could I request Java garbage collection externally, starting the program from JAR (Windows BAT used)? From the Java code I can do it with System.gc() When running a JNLP distribution, I get this "Java console" turned on from Control Panel / Java / ... and this Java console provides manual garbage collection. But... When I'm...

how to write java program get pid

how to write java program get pid? ...

Where to put global application data in Vista?

Where in a Windows (Vista) system should I place data that ought to be readable and writable by everyone, i.e. every user of the computer? Vista's concepts of C:\Users\xxx\AppData\something, C:\Program Files and C:\ProgramData directories and UAC are a bit confusing. Furthermore, is there any ready solution to determine those locations ...

Is there a way to enable double buffering for SWT components?

In the Eclipse RCP application I'm building, I noticed that when I rebuild parts of the GUI (by adding/removing controls), the GUI gets updated and redrawn immediately upon each modification, which causes a flicker effect. Is there a way to enable double buffering, so that the GUI refresh will happen only once at the end of the event di...

Eclipse class designer and design<--> java source bindings

Hi Guys, I'm tutoring a subject on rapid prototyping at university for 2nd/3rd year students. Can anyone recommend a (free) way to design class hierarchies in a GUI design surface within Eclipse? The UML design surfaces in Eclipse Modelling Tools are almost perfect, but I can't find any documentation about how to bind these to java s...

How to debug JVM resources loading?

Hi everybody, this is my first question here in stackoverflow (and I hope not the last one :P). To debug class loading in a JVM we can use the param -verbose:class, but... Anyone knows how to debug resources loading (e.g. properties files)? Thank you in advance! ...

[Java] use of delimiter function from scanner for "abc-def"

Hi! I'm currently trying to filter a text-file which contains words that are separated with a "-". I want to count the words. scanner.useDelimiter(("[.,:;()?!\" \t\n\r]+")); The problem which occurs simply is: words that contain a "-" will get separated and counted for being two words. So just escaping with \- isn't the solution of c...