When building a suite of unit tests for Java code, is there a convention for where to place test code in relation to source code?
For example, if I have a directory /java that contains a bunch of .java source files, is it better to put the test cases in /java itself or use something like /java/test.
If the latter is preferred, how do y...
I'm looking for a java socks Proxy client class that supports authetication, any suggestions? The java.net.Proxy does not support authentication.
Edit:
I can't seem to find a way that would attach authentication data to particular proxy host via socket. Authenticator.setDefault() allows only one set of credential.
Authenticator.s...
How does C# cope with file separators? Is it always assumed the file separator is "\" (or "\\" and does this have to be escaped like this?
...
I am trying to complete the first exercise of USACO.
How can you make the following code more efficient?
It seems that the current problem in the program is that its execution takes too much time.
Thank you for suggesting the first four sets of improvements!
I made a few edits based on your comments.
5th edition of the code
/*
...
hi,
I would like to know if it's possible in java to declare a variable local to the execution of the method.
For instance, if i'm doing some recursive stuff and i want to keep various counters specific to one particular execution of the method.
I don't know the correct english expression for that...
...
How can you write the following statement in the given languages?
a(0) = 1
a_(n+1) = 1 - 1 / ( a_n + 3)
I need to find the smallest value of n when a_n -> 0.732050....
My attempt in Mathematica
a[(x+1)_] = 1 - 1/(a[x_] + 3)
The problem is apparently in this a[(x+1)_].
However, I do not know how to do it iteratively in Mathematica....
Recently, I hit a very perplexing error while trying to clean up my spring configs. The exception was being thrown from deep within a third party library and was basically an obfuscated NPE.
What I would like to be able to do is configure spring to require a specific field on this class as being required, but I do not want to build a cu...
Is there a ready-made C# equivalent to Java's DigestUtils.md5Hex(String)? My Java is rusty, but I can say that DigestUtils is part of the Apache Commons Codec package, and the md5Hex(String) method essentially uses MessageDigest.getInstance("MD5").
(One related tidbit, both the Java and C# code are using UTF8.)
In the simplest of t...
I am a long time user of Python and really like the way that the dictionaries are used. They are very intuitive and easy to use. Is there a good Java equivalent to python's dictionaries? I have heard of people using hashmaps and hashtables. Could someone explain the similarities and differences of using hashtables and hashmaps versus pyt...
I know that in Java, it is common practice to use "get" as a prefix to an accessor method. I was wondering what the reason for this is. Is it purely to be able to predict what it is returning?
To clarify: In some java classes (eg String) a variable like length can be accessed by calling "length()" rather than "size()". Why are these met...
A Visual Studio user struggling w/ Eclipse...
I imported a set of servlets/JSPs into a project in Oracle Workshop for Weblogic. /page.jsp has the following import statement: import="com.foo.bar.*" Eclipse is displaying an error "The import com cannot be resolved". The class that implements the above import in /WEB-INF/src but I don...
I want to design a special calculator ..
and I came to a problem like this :
X=1+(12*4+2)
i need to get number of operands first
like here i have two operands 1 and (12*4+2)
how could i distinguish between the outer + and the inner one ?
thanks
what an amazing community here ..
different answers from easiest to hardest ..
guyz my pro...
I'm trying to access @Service defined class
Interfaces are defined, here is an implementation
@Service
public class TypeServiceImpl implements TypeService {
@Autowired
TypeDAO dao;
public List<DocType> findAll() {
System.out.println("accessing findAll"); //have no appearence
return dao.findAll();
}
...
Hi there,
Anybody aware of how to call a webservice from Java, whats the recommended way, do i need to download an additional JAR or something?
Anybody know of a good tutorial.. i saw something ksoap but it seems pretty old??
The webservice is actually hosted by WCF on .net but i shouldn't think this makes a difference...
I was hopin...
What is eligible way to implement double buffering in JOGL (Java OpenGL)?
I am trying to do that by the following code:
...
/** Creating canvas. */
GLCapabilities capabilities = new GLCapabilities();
capabilities.setDoubleBuffered(true);
GLCanvas canvas = new GLCanvas(capabilities);
...
/** Function display(…), which draws a whi...
How can I create a method that recieve two arrays as parameters and return an array filled with the items that were in both arrays?
Input (Array1 passed in method): ["Lisa", "George", "Mario"]
Input (Array2 passed in method): ["Luigi", "Susan", "Lisa"]
Method should return: ["Lisa"]
I cannot use any built in methods so I have to build...
I need to create and store thumbnails (of images from the web) and store them on the server. Can I use the awt libraries (as listed below) on a linux server running in a datacenter (without a monitor)? I do not know if the server has a graphics card or needs one for these libraries to work...
import java.awt.GraphicsConfiguration;
impo...
I'm trying to parse JSON in android but am having trouble with accessing sub children of an object. I am trying to extract augment from the following,
{"augment-list": {
"time": "12:01",
"channel": "channel1",
"augment": [
{"id": "123", "name": "here", "x": "5", "y": "10", "orientation": "up", "content": "some stuff"},
...
Hi all,
My app makes an outbound connection to a server using a specific source port (in anticipation of firewall problems - a hardened system will probably require ports to be specified ahead of time).
My problem is that my app makes the connection initially. However, if the connection ever breaks it will try again but the socket wil...
Hello,
I can't find a decent Cocoa Charting Library so I would like to use JFreechart.
Is there any way to call a Java program from a Cocoa Application?
I was thinking in writing a java application that returns an image of the chart and I would display it inside my Cocoa app.
Thank you,
...