java

Keyboard shortcut for refactor/selection/editor options in NetBeans?

In NetBeans IDE where you have an icon appear next to a line of code (for example containing refactoring options) what is the keyboard shortcut to expand that menu? Thanks ...

2 ways to get page url in java applets, what's the difference and/or benefits of each?

Hi experts,,, the two ways that I know to get the page url are: 1.through the applet class: Applet.getDocumentBase() 2.through the netscape javascript library: JSObject.getWindow(this).eval("location.href") First, what are the differences between those two methods and advantages of each, Secondly, can users trick the url of those met...

What causes java.lang.IncompatibleClassChangeError?

For some reason our java library that we package as a jar is throwing all of these java.lang.IncompatibleClassChangeError when we try to invoke methods from it. It seems to be seemingly random. What would cause this error? ...

eclipse set global environment for all projects

for each project, i able to set environment when i select "run it as" . can i set global environment that all project will inherit when run? ...

Using JMockit to mock autowired interface implementations

We are writing JUnit tests for a class that uses Spring autowiring to inject a dependency which is some instance of an interface. Since the class under test never explicitly instantiates the dependency or has it passed in a constructor, it appears that JMockit doesn't feel obligated to instantiate it either. Up until now we have been us...

OpenCMS - Best approach for showing rotating references

Hi, I would like to add on the right column of my site a rotating references section. Each reference would have some text + name of person + company name. It does not need to be structured (open text is also ok). I would then want opencms to rotate between 20 difference references each time a page is displayed. I can keep a session sco...

Executing untokenized command line from Java

I am currently using ProcessBuilder to run commands from a java server. This server is to replace an old Perl server, and a lot of our legacy code specifies platform specific command lines. For instance, on windows it might do: command -option "hello world" and on unix it might do: command -option 'hello world' The problem is t...

JAVA: How to scale threads according to cpu cores?

Hi everyone, I'm new to this site and glad to be here :). I'm not a good java programmer, it's just my hobby, but I'm eager to know more than average stuff. I want to solve a mathematical problem with multiple threads in java. my math problem can be separated into work units, that I want to have solved in several threads. but I don't ...

eclipse on maven project warning 'DTD or XML schema'

Description Resource Path Location Type No grammar constraints (DTD or XML schema) detected for the document. TEST-net.kindleit.gae.example.server.MessageRepositoryTest.xml /projecttest-gae-example/target/surefire-reports line 1 XML Problem No grammar constraints (DTD or XML schema) detected for the document. appengine-web.xml ...

Is there a Java equivalent to C#'s 'yield' keyword?

I know there is no direct equivalent in Java itself, but perhaps a third party? It is really convenient. Currently I'd like to implement an iterator that yields all nodes in a tree, which is about five lines of code with yield. ...

Launching Eclipse as a debugger

What’s the equivalent of System.Diagnostics.Debugger.Break(); in the Java world? Purpose: I have a tomcat based webapp launched by a custom build tool and need to debug the application in eclipse. In the .net world the above statement when encountered will prompt the OS to attach a debugger and I can attach Visual Studio to deb...

Java Closures - Current State

There have been many threads that correspond to this topic. http://stackoverflow.com/questions/116865/whats-the-current-state-of-closures-in-java http://stackoverflow.com/questions/233579/closures-in-java-7 All of the inputs have been that java 7 is NOT getting closures. It seems however closures will now be in java 7: http://weblogs...

Java's CORBA ORB and connecting to a 3rd party Naming Service

Hi all, The Following is from JavaTM IDL FAQ: How do I connect to a 3rd-party Naming Service from Sun's ORB? The recommended way is to use the Interoperable Naming Service (INS) , if this option is supported by the 3rd-party Naming Service. To use the Sun ORB with another vendor's Naming Service, Start th...

Send data to HTTPservlet in android

This is the servlet code in java ME. protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); ArrayList<String> listName = new ArrayList<String>(); ArrayList<Integer> listLongitude = new ArrayList<Integer>(); ArrayList<I...

Java Scanner question

How do you set the delimiter for a scanner to either ; or new line? I tried: Scanner.useDelimiter(Pattern.compile("(\n)|;")); But it doesn't work. ...

Java file not written to stream with new line characters

We're streaming a CSV file from a web service. It appears that we're losing the new line characters when streaming - the client gets the file all on a single line. Any idea what we're doing wrong? Code: public static void writeFile(OutputStream out, File file) throws IOException { BufferedReader input = new BufferedReader(new Fi...

Pre-creating objects in a separate thread

Suppose I have a Java method like: public Ouput respond(Input input) { /* .. */ } The Output object has many fields - some of those fields depend on the Input object but the rest are pre-determined. I want to make the thread which calls respond() to return as fast as possible. For this I want to spawn another thread which pre-creates...

Loading external source code and using them internally (by re-compiling or something)

Hi, Is there a way in using externally stored sourcecode and loading it into a Java programm, so that it can be used by it? I would like to have a program that can be altered without editing the complete source code and that this is even possible without compiling this every time. Another advantage is, that I can change parts of the co...

Why is call to static method in Java not being made?

I have a fairly standard creational pattern whereby a class exposes a static method for returning instances of itself, like so: public class MyClass { private MyClass(/*parameter list*/) { // internal construction } public static MyClass GetMyClass(/*parameter list*/) { return new MyClass(/*parameter li...

Remove Emaill address from java string

Hi All, How can I remove email address from a string? And all other digits and special characters? Sample String can be "Hello world my # is 123 mail me @ [email protected]" Out put string should be "Hello world my is mail me" I googled this and found that I can use following regular expressions "[^A-Za-z0-9\\.\\@_\\-~#]+" but tha...