java

scala dot syntax (or lack thereof)

I was going through the wonderful book, Programming in Scala when I came across a piece of code that just doesn't make sense to me: def above(that: Element): Element = { val this1 = this widen that.width val that1 = that widen this.width elem(this1.contents ++ that1.contents) } Note line 2 and 3: val this1 = this widen th...

How can I launch an Eclipse command from Java?

How do I launch a find and replace command without the user clicking edit->find replace or ctrl+F? I need to do this with a plug-in written in Java. ...

Import outlook contacts from a webpage with an Java Applet or ActiveX Control

Hi I want to import Outlook Contacts of a user when he accessed the webpage with a Java Applet or an ActiveX Control. Is there any library to access the contacts or I can copy the .pst file on my server and then parse it and find the contacts ? I found Java Outlook Connector http://www.moyosoft.com/joc/ Thank you ...

How to replace a dynamic library loaded in a Java Applet without requiring a full browser restart?

Hi, I'm writing a self-updating application. The first time it runs, it installs a native library on the client's computer, so that they don't need to download it every time. When it detects that the installed library's version is older than the new required minimum, it downloads and installs the new one. The problem is, the new librar...

upload file in JSP - how to change a default path for the uploaded file

I have two jps pages to handle an upload of the single file. Here is a code for selecting a file: org.apache.commons.io.FilenameUtils, java.util.*, java.io.File, java.lang.Exception" %> ... <form name="uploadFile" method="POST" action="processUpload.jsp" enctype="multipart/form-data"> <input type="file" name="myfile"><br...

What is the difference between JAIN SIP and MJSIP?

Hi, I've been investigating various API options for making use of the SIP (Session Initiation Protocol) in Java. So far I've narrowed it down to JAIN SIP and MJSIP but I can't figure out the difference between the two. Can someone please explain why and when to choose one over the other? Thanks in advance. ...

media conversion library/plugin preferably php

I am looking for an media conversion library that can convert and compress various media i.e both audio and video files to various formats. ...

Are threads really not being garbage collected on WTK emulator?

I'm pretty sure I'm not going mad when I say that Thread objects do not seem to be garbage collected in my J2ME application when running on the WTK emulator (v 2.5.2_01). I have a console message when my run method exits, and it is printed. At the same time I make a call back to the only object that has a reference to the thread and tel...

Two charset tags on a page, which to take?

I'm working on crawling pages for information, and have run into many problems with parsing the pages in Groovy. I've made semi-solution that works most of the time using juniversal chardet and just scanning the page for tag in the head, but sometimes two of these tags are found on one page, for example: <meta http-equiv="Content-Ty...

Tomcat: how to get the secure port number in Java?

I'd like to embed a link to a secure page of my application in one of my unsecure pages. The secure tomcat port is configured in the server.xml file. In some deployments it's 443, 8443 etc. So what I need is a way to read the secure port from tomcat configuration to use it in the link. Is that possible? Alternatively, simply getting acc...

Managing a Large OSGi Application

Hello, I have a large, growing OSGi application with a number of bundles. I am curious to know the best way to manage this type of application. Currently, I am using Eclipse and Maven, but although this is great for building bundles (via maven-bundle-plugin), as of now it has not been easy to manage the entire application. What I would...

what are the usages of atomic ways?

how atomic ways can make our codes thread-safe? ...

testing hibernate parent/child relationship

hello good fellas! i use spring and hibernate for my data access layer i'll like to have some guidance about how to construct my unit testing to test if hibernate is effectively insert in the child table(parent hibernate mapping has the cascade all on the set). For what i know i shouldn't mix dao's unit testing.So supposing the i'm testi...

Default Fonts in Java

I have some Swing code (written in 1.6 for 1.6) that specifically sets the font in a text area to Courier, but on some Windows systems, this shows up as Arial (the system default?) instead. Does that mean a font is missing from the system? What is the behavior Java has when it can't find a font it is looking for? Does it complain? Do...

How to get current EAR location programmatically with JBoss

Hi there! Does anyone know how to get programmatically the absolute path in the filesystem for an EAR deployed in JBoss, from Java code within that same EAR? I need this because I want to copy some files that are inside the EAR to another part of the filesystem, on deploy-time. Thank you everyone! ...

Best ways to handle maximum execution time for threads (in Java)

So, I'm curious. How do you handle setting maximum execution time for threads? When running in a thread pool? I have several techniques but, I'm never quite satisfied with them. So, I figure I'd ask the community how they go about it. ...

How do I replace a character in a string in Java?

Using Java, I want to go through the lines of a text and replace all ampersand symbols (&) with the XML entity reference &amp;. I scan the lines of the text and then each word in the text with the Scanner class. Then I use the CharacterIterator to iterate over each characters of the word. However, how can I replace the character? Firs...

Internal Server Error

I am getting an unusual error while running my application, just wondering if anyone has come across this before. I am using google protocol buffers, my servlet takes a request and tries to process it, I have the following code: InputStream s = request.getInputStream(); AdRequest adRequest = AdRequest.parseFrom(s); After executing th...

Session objects into Seam Interceptors

Hello guys, once more i'm here asking help on seam subject. Currently we have the following interceptor for audit @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @Interceptors(LoggingInterceptor.class) public @interface IAuditavel { } and the interceptor itself private EntityManager em; @Logger private Log lo...

JSF/ICEFaces takes very long time in rendering response

Hello, I have a JSF/ICEFaces application that was working fine but all of the sudden it started taking sinfully long time in rendering response phase! I can tell from the console that the java part completes fine but it takes like 10 minutes to display the web page! I'm using JBoss as my application server. Could you please tell me ho...