java

How can a class access its own classname?

I use an java application which generates a class dynamically. Via an ant script the source code will be produced for a give classname and a class template. In the template for the class I need to know the name of even this class, to call a static method of the class. Example. The class will be named "VersionInfo". Then in static main(...

Loading a popup using ajax

I have a jsp page which should load a popup using ajax. The content of the page is determined by form filled by user. Something like this: javascript: ajax('getPage.action', 'content_id', 'form_id'); foo.jsp: <div id="content_id"></div> <form id="form_id"> ... </form> java/spring: @RequestMapping("getPage.action") MyController...

Launch file from Java

I want to launch a file(a document) from a Java program and phase the following requirements: Method must be applicabale on Mac, Win and Linux systems I am not allowed to use "Runtime.getRuntime().exec("cmd.exe /C +"filename"); The file I am launching needs to be either of .doc / .docx / .rtf The file is created runtime, a result fro...

Renaming a File/Folder inside a Zip File in Java?

I have a zip file containing a folder structure like main-folder/ subFolder1/ subFolder2/ subFolder3/ file3.1 file3.2 I would like to rename folder main-folder to let's say versionXY inside that very zip file using Java. Is there a simpler way than extracting the whole zip file and recreating a new one using the new folder names...

How can I verifiy signed JARs with pure Java?

I don't want to use the jarsigner -verify. Is there no JAR util package for my problem? I just want to verfiy a JAR in pure Java. ...

Copying Excel Worksheets in POI

Does anyone know of a means to copy a worksheet from one workbook to another using POI? The Workbook class has a cloneSheet method, but there doesn't seem to be able to insert a cloned sheet into a new workbook? If there isn't an API to do this easily, does anyone have the code to copy all of the data (styles, column widths, data, etc) ...

Regex optimisation - escaping ampersands in java

I need to replace all & in a String that isnt part of a HTML entity. So that the String "This & entites &gt; & &lt;" will return "This &amp; entites &gt; &amp; &lt;" And I've come up with this regex-pattern: "&[a-zA-Z0-9]{2,7};" which works fine. But I'm not very skilled in regex, and when I test the speed over 100k iterations, it uses...

making a .jar file with source and project structure?

I wonder if this is possible with ant and java: I have a Java project which looks like this: ./ build.xml src/ com/ example/ {.java files here} bin/ com/ example/ {compiled .class files here} lib/ {3rd-party jar files here} dist/ {jar file(s) here} I know how to make a .jar file...

Sending 100 Continue using Java Servlet API

Is it possible to send "100 Continue" HTTP status code, and then later some other status code after processing entire request using Java Servlet API (HttpServletResponse)? I can't find any definitive "No" answer, although API doesn't seem to support it. ...

Problem with Painting in Java Swing App in Java 1.6

Hi, I'm working on a Swing application (currently running on Java 1.6 update 11) which has some intermittent paint refresh problems (e.g. there are artifacts etc.). This only happens to some users of our application but not others. After doing some research, I found that setting the property sun.java2d.d3d to false may help and in fact...

Java release engineering good practices

I've got a fairly simple open-source Java project I am starting. This process is new to me, I'm used to writing programs just for myself. What are some good practices to be aware of when releasing open-source projects in Java? Here are some things I can think of, can you suggest others? version control repository (what do you use to e...

Saxon 8 (Java version) problem

I'll point out now, that I'm new to using saxon, and I've tried following the docs and examples in the package, but I'm just not having luck with this problem. Basically, I'm trying to do some xml processing in java using saxon v8. In order to get something working, I took one of the sample files included in the package and modified to...

Have com.l2fprod.common.propertysheet.PropertySheetPanel To Display Composited Class

In order to have a Netbeans liked property inspector windows, I am making use of the following class to help me achieve this. com.l2fprod.common.propertysheet.PropertySheetPanel So far, it works fine for class with simple properties like String, int... However, when come to slightly complicated class with composited relationship, thin...

Is there a Java library for muslim prayer times calculation?

Can anyone tell me where to find a Java library that does Muslim prayer time calculation based on the city? Maybe a web service? I would prefer a Java library. ...

In a Tomcat cluster, how to share beans in an application?

This might sound like a dumb or a simple question, but I really have little to no experience with clustering of any kind and I'm just curious if and how a certain scenario is possible. Let's say I've set up a cluster of N Tomcat instances, and I've deployed my application App1 across all N instances. What would I need to do to be able ...

Why does the maven-assembly-plugin puts the same dependency in my zip multiple times?

I put together an assembly descriptor <assembly> <id>all</id> <formats> <format>zip</format> </formats> <includeBaseDirectory>false</includeBaseDirectory> <moduleSets> <moduleSet> <includes> <include>org.openscada.atlantis:org.openscada.atlantis.core.common</include> <include>org.openscada.atlantis:org.openscada.atlantis.net.b...

Smart electric brace in cc-modes (C#, Java, etc.)

In various IDEs, typing an open-curly results in the appearance of a matched pair of brace characters. Typically the braces are inserted in some context-sensitive way. Within a string literal, there is no intervening newline inserted between the braces. Outside a string literal, there is a newline, and things are indented immediately....

Sending email in Java?

Can anyone suggest a library for sending emails in Java? ...

emacs typeover skeleton-pair-insert-maybe

In Eclipse, editing Java code, if I type an open-paren, I get a pair of parens. If I then "type through" the second paren, it does not insert an additional paren. How do I get that in emacs? The Eclipse editor is smart enough to know, when I type the close-paren, that I am just finishing what I started. The cursor advances past the cl...

@EJB annotation in clients

Using NetBeans, I do the following in the class containing main(), and it works: import javax.ejb.EJB; public class Master { @EJB TestBeanARemote x; public static void main(String[] args) { Master m = new Master(); m.doStuff(); } //doStuff includes x, but it works, so who cares. ... If I do that in a ...