java

Java String in Javascript function

I want to pass a Java string variable to Javascript function which I am calling in Java code. Somehow the value of string remains as null. Is there any way to do this? Here is some sample code cb.set(CheckBox.ONCLICK,"displayCB(" + e.getFormName() + ",document.Profile.UniqueForm"+"_TestOpt)"); So in above line of code i am calling di...

PreparedStatement not returning ordered ResultSet

I am having some problems and I'm sure it's something stupid. So I have a query like SELECT name, id, xyz FROM table ORDER BY ? then later down the road setting the ? doing a ps.setString(1, "xyz"); I am outputting the query and the value of xyz in the console. When I loop through the ResultSet returned from the PreparedStatemen...

Delay in multiple TCP connections from Java to the same machine

(See this question in ServerFault) I have a Java client that uses Socket to open concurrent connections to the same machine. I am witnessing a phenomenon where one request completes extremely fast, but the others see a delay of 100-3000 milliseconds. Packet inspection using Wireshark shows all SYN packets beyond the first wait a long ti...

WHERE is tomcat.conf in ubuntu ?

I can't find it, I have looked at: /etc/tomcat6 cd ~tomcat6 -> /usr/share/tomcat6 Where can I find the tomcat.conf in Linux Ubuntu? ...

Homework: Java IO Streaming and String manipulation

In Java, I need to read lines of text from a file and then reverse each line, writing the reversed version into another file. I know how to read from one file and write to another. What I don't know how to do is manipulate the text so that "This is line 1" would be written into the second file as "1 enil si sihT" ...

Is it possible to change the priority of garbage Collector thread?

Java garbage collector runs with priority 1, due to which it is not guaranteed that System.gc() will actually execute if called. Is there any way to change its priority? This shall enable me to run if I want. ...

Can I use JDT to rename a working copy of a Java source file?

I'm using Eclipse JDT to build a Java refactoring platform, for exploring different refactorings in memory before choosing one and saving it. I can create working copies of the source files and edit them (for example to rename a type, using ASTRewrite), and I also want to rename one or more of the working copies. I'd hoped that the renam...

Excecute iwconfig from a java application

Is it possible to execute iwconfig (or any other shell based program) from a java application and then parse the output somehow? If yes, how? ...

Can I use Eclipse JDT to create new 'working copies' of source files in memory only?

I'm using Eclipse JDT to build a Java refactoring platform, for exploring different refactorings in memory before choosing one and saving it. I can create collections of working copies of the source files, edit them in memory, and commit the changes to disk using the JDT framework. However, I also want to generate new 'working copy' sou...

How to define person's names in text (Java)

I have some input text, which contains one or more human person names. I do not have any dictionary for these names. Which Java library can help me to define names from my input text? I looked through OpenNLP, but did not find any example or guide or at least description of how it can be applied into my code. (I saw javadoc, but it is pr...

How should I implement this HashMap's equals and hashCode methods to represent an automaton state?

I want to put State objects (which are HashMaps with Character as key and State as Value into an ArrayList named allStates. Should I override the equals and hashCode methods here? Why? How? This code is for the Automaton and State classes I've built so far: class State extends HashMap<Character, State>{ boolean isFinal; boolean isIni...

Java Ajax Framework integration

Hi, I'm looking for a java AJAX framework which I can include into my existing webapp. I've found sweetDev RIA . Are there such other frameworks which I could look into it? ...

Java: Easier pretty printing?

At the end of my computations, I print results: System.out.println("\nTree\t\tOdds of being by the sought author"); for (ParseTree pt : testTrees) { conditionalProbs = reg.classify(pt.features()); System.out.printf("%s\t\t%f", pt.toString(), conditionalProbs[1]); System.out.println(); } This produces, for instance: Tree Odds of...

Is there a Java Scripting Language that Can Work Without Caching? Jython? Groovy? etc?

Hi all, We have an existing java-based heavyweight project that needed an interactive script interpreter. After a fair amount of research we eventually ended up with Jython, one of the reasons being that the customer's group already has a large amount of python expertise, and it's an easier sell to give them an api in a language c...

Setting values from a class to Spring context file

We usually define some beans with their properties in the Spring context file and write some setter methods in the class. Let's say I wanna do the opposite. I have a bean in the context file and want to declare some properties from the class..or initialize values of declared properties in the context from the class. How do I do that? ...

How to make my java search tool work...

So I written up a small script to search in a folder in the current directory named /files/ All files are in *.txt file format and the tool will find any string inside the file. This does not search for file names, only the contents of the file: Example of my problem: Enter string to find: Enter string to find: 6570 Enter string to ...

Calculate the DEPTH of a binary search tree?

Original problem: Calculate the number of nodes [SOLVED]. I have another similar problem, and both of these have been killing me for a while now. I can calculate the number of words fine now. Thank you very much for your assistance. The issue is now calculating the summation of depths [the sum of the individual depths for all childre...

Java JMenuItem Accelator Snow Leopard

about = new JMenuItem("About"); about.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A((Toolkit.getDefaultToolkit().getMenuShortcutMask())))); JMenu help = new JMenu("Help"); help.add(about); I was wondering why my aaccelerators were not working. I am running this in snow leopard with JavaSe-1.6 VM. They do work if I pull the menu d...

How to set a breakpoint on a default Java constructor in Eclipse?

In Eclipse, I would like to set a breakpoint on a Java default constructor. I can't simply double click to the left of any line of code since default constructors have no source code - they are implicitly generated by the Java compiler. I'd like to be able to set such a breakpoint without modifying the existing code. ...

Calculate the depth of a binary search tree?

I am having difficulty calculating the summation of depths [the sum of the individual depths for all children of the root] for a given BST. I have the total number of nodes for the tree, and I am trying to calculate the average depth for the tree, requiring I have this depth sum. Recursion and I don't get along very well.. I am finding ...