java

Best way to run remote commands on a Windows server from Java?

Are there any existing solutions for remote execution of commands on a windows server from Java natively? psexec.exe is not an option since the java application has to be cross platform. Even a preexisting solution using Java RM would be sufficient. Currently, I'm using an SSH client library to ssh through java into a Windows server th...

Different spring XML files for development environment vs. deployment when using maven

Summary We have a central LDAP server that our deployed Java web app should connect to. Our JUnit tests depend on specific data in the LDAP repository, so they need to connect to an embedded ApacheDS LDAP server, primed with a sample data set. How do we make sure that the ApacheDS server doesn't start up when we deploy our webapp? De...

What reason is there for C# or Java having lambdas?

What reason is there for C# or java having lambdas? Neither language is based around them, it appears to be another coding method to do the same thing that C# already did. I'm not being confrontational, if there is a reason I would like to know the reason why. For the purpose of full disclosure I am a Java programmer with a C++ backgroun...

How do I change the default application icon in Java?

I'm using NetBeans, trying to change the familiar Java coffee cup icon to a png file that I have saved in a resources directory in the jar file. I've found many different web pages that claim they have a solution, but so far none of them work. Here's what I have at the moment (leaving out the try-catch block): URL url = new URL("com/x...

From what Linux kernel/libc version is Java Runtime.exec() safe with regards to memory?

At work one of our target platforms is a resource constrained mini-server running Linux (kernel 2.6.13, custom distribution based on an old Fedora Core). The application is written in Java (Sun JDK 1.6_04). The Linux OOM killer is configured to kill processes when memory usage exceeds 160MB. Even during high load our application never go...

Code / template generator for Java

For C#, I have often used CodeSmith and lately the T4 generator which is part of Visual Studio. I'm looking for something similar for Java, in particular an Eclipse add-in since I do all my Java development using the Eclipse IDE. ...

For a typical Web 2.0 Social Application - Java vs C#

For a product in long run (may be 0.5-1 million users) is it good to use java instead of .net from the cost/profitability perspective. To elaborate more..consider web farm scenario in which one will have to purchase windows + Sql server + some antivirus licenses for .net applications. But for java it's almost free. What points should I c...

Learning Java Swing?

I am a veteran C/C++ programmer who has used Win32, MFC and WTL to write Windows apps for many years. I have some very basic Java experience, but haven't done anything with a UI. I want to start learning how to write desktop apps in Java and from what I can gather, Swing is the way to go. My question is: where do I start? Can anyone ...

How do I set up my environment for ESC/Java2 in Windows and build/run with ESC/Java2?

How do I set up my execution environment for ESC/Java2 in WindowsXP? And furthermore, how do I build and run, in WindowsXP, projects with ESC/Java2. It is hard to tell from their specifications/readme and documentation, specially considering the fact that they seem to be talking more about Unix based operating systems. ...

Interface too general

In the Java code I'm working with we have an interface to define our Data Access Objects(DAO). Most of the methods take a parameter of a Data Transfer Object (DTO). The problem occurs when an implementation of the DAO needs to refer to a specific type of DTO. The method then needs to do a (to me completely unnecessary cast of the DTO to ...

YAWS fronting Tomcat

Is there currently any easy way to set up a YAWS web server in front of Apache Tomcat Servlet container, similar to popular Apache httpd + Tomcat set up? ...

Package structure for a Java project?

Whats the best practice for setting up package structures in a Java Web Application? How would you setup your src, unit test code, etc? ...

JSP: How can I still get the code on my error page to run, even if I can't display it?

I've defined an error-page in my web.xml: <error-page> <exception-type>java.lang.Exception</exception-type> <location>/error.jsp</location> </error-page> In that error page, I have a custom tag that I created. The tag handler for this tag e-mails me the stacktrace of whatever error occurred. For the most part this works great....

Readings on writing high-performance server in Java

Hi, Could anyone please introduce books/papers/articles that I should read If I want to write a high-performance RPC server in Java, which handles large number of concurrent connections(C10K or over), is fault-tolerant, can be scaled out, and maintains high throughput? Thanks! ...

Can you override the formatter for a specific log in log.properties

I am using log.properties to configure logging for a Java app. Each class gets its own logger named after itself (e.g. com.company.program.ClassX). I want to set a custom formatter for just one log, and leave the handler with the SimpleFormatter. Is this possible? I am not interested in using log4j or another of the other logging suite...

Java “must-have” development tools

Java doesn't seem nearly as "well served" as .NET with tool lists on the Internet. There's James Selvakumar’s article entitled "Must have tools for a Java Developer" which has items I don't agree with. (Do FireFox and MySQL qualify as development tools?). There is also the Java Power Tools book. Assuming you already have a half-decent ...

What is the best way to initialize a bean?

In spring you can initialize a bean by having the applicationContext.xml invoke a constructor, or you can set properties on the bean. What are the trade offs between the two approaches? Is it better to have a constructor (which enforces the contract of having everything it needs in one method) or is it better to have all properties (wh...

Canvas3D not appearing in Swing window

I am attempting to insert a Canvas3D object inside a Swing JPanel, but the code doesn't seem to be working (i.e. nothing happens): Canvas3D canvas = new Canvas3D(SimpleUniverse.getPreferredConfiguration()); SimpleUniverse universe = new SimpleUniverse(canvas); BranchGroup root = new BranchGroup(); root.a...

Storing the state of a complex object with Memento pattern (and Command)

Hello, I'm working on a small UML editor project, in Java, that I started a couple of months ago. After a few weeks, I got a working copy for a UML class diagram editor. But now, I'm redesigning it completely to support other types of diagrams, such a sequence, state, class, etc. This is done by implementing a graph construction framew...

Do you use Javadoc for every method you write?

Should I be writing Doc Comments for all of my java methods? ...