java

Eager java class loading

I'm trying to do some benchmarking of JVMs running on various hardware and OS platforms. I've created an algorithm to exercise the parts of the JVM I'm interested in and intend to run this algorithm many times to find a decent average. When I run the benchmark, I find that the first run is significantly longer than subsequent runs: 13...

Convert HTML Character Back to Text Using Java Standard Library

Hello all, I would like to convert some HTML characters back to text using Java Standard Library. I was wondering whether any library would achieve my purpose? /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here // "Happy & Sad" in HTML form. String ...

Java Authenticator on a per connection basis ?

I'm building an eclipse plugin that talks to a REST interface which uses Basic Authentication. When the authentication fails i would like to popup my plugin's settings dialog and retry. Normally I could use the static Authenticator.setDefault() to setup an authenticator for all HttpURLConnection's for this but since i am writing a plugi...

recommmendations Java libary for SMS gateway international.

I want to make program it's can send sms to person in other country. I heard using sms gateway international can do it, and cheap (or maybe free). So, i want to know the best library for it . Thx i'm using netbean 6.5 for making program. ...

run exe which is packaged inside jar

Hi, I am executing an exe through my java program. the path is hardcoded in java. I have packaged my the exe in the jar. But am stuck as i have the path name hardcoded in the java file. so am not able to execute my jar as a stand alone program. Any hints for packaging such jar i.e having an exe inside and able to run it as a stand al...

Java appears hung

I've been using the Java Service wrapper in a custom application for quite a while and it's been working fine. Since updating our application to a new version in the last few days the JVM started hanging and then wrapper prints this in the log: JVM appears hung: Timed out waiting for signal from JVM. It then automatically terminates th...

What is the difference between passing by reference in Java and passing a pointer in C?

I have been studying Java for a few months and am now starting to learn C. I am a little confused, I was under the impression that passing an object by reference and passing a pointer to that object were the same thing: I thought the difference was that in Java all passing of objects is done with pointers automatically, where as in C o...

Using Java to find substring of a bigger string using Regular Expression

If I have a string like this: FOO[BAR] I need a generic way to get the "BAR" string out of the string so that no matter what string is between the square brackets it would be able to get the string. e.g. FOO[DOG] = DOG FOO[CAT] = CAT ...

Java Threadpool vs. new Thread in high request scenario

I have some old java code for a REST service that uses a separate thread for every incoming request. I.e. the main loop would loop on socket.accept() and hand off the socket to a Runnable which then would start up its own background thread and invoke run on itself. This worked admiringly well for a while until recently i noticed that the...

In Eclipse plugins, is there a programmatic equivalence to the markerAnnotationSpecification extension point?

The extension point org.eclipse.ui.editors.markerAnnotationSpecification is used to change how certain user-defined text annotations appear in the editor. Is there a way to create or modify or override these programatically from a plugin? ...

Java Image messes up when I run the .jnlp file

I have a method that gets called at the start of my program, and it works fine when I run the jar, but when I run the jnlp file it crashes. public void newImg(String i) { try { File file = new File(i); img = ImageIO.read(file); } } img is a bufferedImage, by the way. ...

How to output a string attribute on an object that may be be null

As part of a dataTable in a seam JSF page, one column requires the output of a name: <h:outputText value="#{listing.staffMember.name}"/> The problem is that "staffMember" may be null on some listings, so I get the error: javax.el.ELException: /xxxxx.xhtml @42,67 value="#{listing.staffMember.name}": Error reading 'name' on type xxxx.m...

Best practice for ignoring year in date for date ranges

I need to model some information about seasons, and need to track them based on start / end date in a year-agnostic way. I.e. I need to allow users to define summer as being between, say, May 15th and September 10th, and do that for all years. I'll need to do a lot of checking of the type isThisDateInSeason). All the date manipulati...

Can a signed Jar be run as an executable?

I ask because I have an unsigned jar that runs and a signed version that doesn't. Looking at the manifests, I see no main class thing for the signed one. Do I have to run a signed jar from web start? ...

JAXB XML output format questions

Hi, I have Java classes with the following structure (the class names do not imply anything, I was just making them up). package test; import java.util.ArrayList; import java.util.List; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Marshaller; import javax.xml.bind.annotation.XmlAccessTy...

Is a finally block without a catch block a java anti-pattern?

I just had a pretty painful troubleshooting experience in troubleshooting some code that looked like this: try { doSomeStuff() doMore() } finally { doSomeOtherStuff() } The problem was difficult to troubleshoot because doSomeStuff() threw an exception, which in turn caused doSomeOtherStuff() to also throw an exception. The s...

"cannot find symbol method drawImage(java.awt.image.BufferedImage,<nulltype>,int,int)"

Okay, now I've been using drawImage in java for a while, and this has never happened before. Why can't it find "drawImage(java.awt.image.BufferedImage,<nulltype>,int,int)" in my code? import java.awt.*; import javax.swing.*; import javax.swing.JPanel; import java.awt.event.*; import java.awt.image.*; import java.io.*; import java....

How do I properly load a BufferedImage in java?

Okay, so I've been trying to load a BufferedImage using this code: URL url = this.getClass().getResource("test.png"); BufferedImage img = (BufferedImage) Toolkit.getDefaultToolkit().getImage(url); This gives me a type cast error when I run it though, so how do I properly load a BufferedImage? ...

Android homescreen shortcut permission error

Hello, In my program it adds a shortcut to the screen. I get the icon on the screen fine, but when I tap it, I get: 03-01 20:00:29.410: ERROR/AndroidRuntime(796): java.lang.SecurityException: Permission Denial: starting Intent { data=http://www.example.com/ flags=0x14000000 comp={com.isaacwaller.example/com.isaacwaller.example.ExampleCu...

exit the batch file after running using java

Hi I know how to start the batch file using java code. When i run the batch file command prompt is opened. To close the command prompt i am using the taskill /im cmd.exe. but the problem is that the command prompt that is used to start the jboss is also closed. i want to kill the cmd with a particular process id. How do i get the proces...