java

How to best install Rhino on OSX 10.6 Snow Leopard

I am running OSX 10.6 Snow Leopard, have downloaded rhino1_7R2 and moved it to /usr/local/ I am aware however that (while this would prevent it from being altered by OS updates) this may not be the best location for it and imagine that it may need to be connected to the Java installation. My intended use for Rhino is to run JavaScript ...

Java code for FTP upload doesn't work properly if launched as windows service

I'm using java code for uploading some files using FTP. When I compile and run the code everything works perfectly, but if I launch it as a windows service using Java Service Launcher, it doesn't connect to the FTP server at all (it just does the rest of the job, that is moving files to archive folder). Btw, is there any better way for ...

Log4j loading up memory?

We can call Log4j in two ways 1) Having static Logger reference in each class of the package and call logger 2) Having one static Logger reference in once 'static' class and refer this 'static' class from every where Based on memory which method is efficient and Which method is good generally? ...

web.xml servlet mapping for wildcard requests

I want one of my servlets (test2) to handles the "/" request (i.e. http://localhost/), while another servlet (test1) handles all other requests ("/*"). I set up my web.xml below, but the problem is that ALL requests go to test1.jsp (even the "/" request) Can someone tell my how to accomplish this? <servlet> <servlet-name>test1</se...

SQL Server / JDBC Connectivity Issues

I am experiencing some strange behaviour in my Java server application whereby database operations that usually take a few milliseconds are sporadically taking much longer (30s - 170s) to complete. This isn't isolated to a specific query as I've seen the delays occurring for both SQL update and select statements. Also, all of my select...

How to remove specific element on List

How to remove specific element on List? ... java.util.List<Polygon> triangles = new LinkedList<Polygon>(); Point startDrag, endDrag, midPoint; Polygon triangle; .... int[] xs = { startDrag.x, endDrag.x, midPoint.x }; int[] ys = { startDrag.y, startDrag.y, midPoint.y }; triangles.add( new Polygon(xs, ys,3)); .... public void mo...

Non-java webApp to authenticate against Java servlet

Hi, We have a J2EE webapp deployed to JBoss. This webapp is used for authentication purposes. Now we would like to have other webApps that are not written in java to communicate and authenticate against this webapp. The reason we want to do this is: Suppose we have a small webapp that does simple task for the user. This webapp could be...

Java MIDI - getting data from piano?

I've inherited a Java project that used an old C++ dll to receive MIDI data from a piano connected to the computer. Now that Java has built-in support for MIDI devices, I want to get rid of the legacy C++ dll and just use pure Java. Does Java support receiving data from a piano connected to the computer? I've searched Google for example...

Draw a triangle using mouse drag (how can I move the previous drawn triangle using mouse drag)

How to move a triangle to a new location using mouse drag (which was previous drawn using mouse drag)? ... java.util.List<Polygon> triangles = new LinkedList<Polygon>(); Point startDrag, endDrag, midPoint; Polygon triangle; ... public PaintSurface() { this.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEven...

How to approach shifting a Java Swing app to a Servlet ?

I want to use the Model-View-Controller template while writing my Web App. The problem is, the Model part of the code has already been written in Swing. The Model code also must require the container to call its main method before any interaction with its servlets. So is there a way for me to specify the location of the main method in th...

Fail to connect to james server localhost

I'm trying to connect to James server localhost, but I'm getting an exception javax.mail.MessagingException: Could not connect to SMTP host: localhost, port:25; nested exception is: java.net.SocketException: Network is unreachable: connect at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1545) ...

How do I do a HTTP GET in Java?

Hello, How do I do a HTTP GET in Java? Thanks. David ...

how to run a batch file from java?

Hi experts, I am trying run a batch file from my java codes, but unfortunately I could not run it properly. Actually the batch file is running but only the first line of the batch file is running, so please give solution to it, here are the codes and the batch file. class bata { public static void main(String [] args) { try { Runtime...

Encoding/decoding REST path parameters

I am trying to find the best way of getting round a design flaw in a web app I'm helping to support. One part of the service passes a parameter ("myparam") to a .jsp page, which in turn calls a REST service including our myparam as a path parameter. The design flaw bit is that myparam should be passed as a form parameter, since it can be...

Gmail Task API exist?

Inside Gmail, there is a small function called "Task". It can allow me to enter a to-do-list. I'm wondering if there is any official / unofficial Google API to access / update the list by Java language? ...

Java Getter and Setter Method

What are getter methods and setter methods in Java? What is their technical term in Java? ...

Log4J properties file - where to put it

I wrote a web service project using netbeans 6.7.1 with glassfish v2.1, put log4j.properties to the root dir of project and use static Logger logger = Logger.getLogger(MyClass.class); in Constructor: PropertyConfigurator.configure("log4j.properties"); and in functions: logger.info("..."); logger.error("..."); ... but, it is error in...

Persisting byte array on the JNDI tree in JBoss

As part of a Java EE application I'm developing on JBoss, I need to persist the contents of a file on the JNDI tree. I'm doing this by reading the contents of the file into a by byte array, then binding it to JNDI as follows. getInitialContext().rebind("customers_datafile", byteArray); This works fine, but the binding is lost when th...

Java: Good way to encapsulate Integer.parseInt()

I have a project in which we often use Integer.parseInt() to convert a String to an int. When something goes wrong (for example, the String is not a number but the letter 'a', or whatever) this method will throw an exception. However, if I have to put exceptions in my code everywhere, this starts to look very ugly very quickly. I would l...

How should I tackle with "Program Crashing" issues?

Hi, I am working on a Java product. An client claims that the application is getting crashed after an arbitrary time. SInce it is a crash we can't find any information on our logs. Are there any tools, methods to find out the reasons for such Issues? Can we do anything in code side to get more information on such program crashes? Can ...