java

How can the disable file operation, file selection and filter panel from JFileChooser(JAVA Swing)?

I need to embed JFilceChooser dialogbox in a Panel. I only need the file and folder view. How can i disable others panel that are included in dialogBox i.e(file operation, file selection and filter panel) from JFileChooser() dialogBox.. Thank you ...

Get Hibernate Entity instance from id column in SQLQuery result

I have (non-Hibernated) database tables that contain ids for Hibernate entities. I can query them (using createSQLQuery), which gives me the ids, from which I can then load the entities. I'd like to do that in one step, and I think I can do that with addEntity, but I am not sure how exactly. (Hibernate's documentation web site is down. ...

Can Maven generate exe files and mac os x apps?

Hi all, Lets say you created a little Java Desktop app with a jar and some dependencies and possibly a license text file. I know there are plenty of Ant tasks that can generate installers, executables and proper Mac OS X applications including packaging them as ".dmg" files. Examples would be JarBundler and Launch4j Does similar things...

Java - DocumentBuilder closing Socket connection

I have a problem with Socket connection closing too fast. I was told I need to temporarily load data from Socket and the parse it. Here is my code: ServerSocket listen = new ServerSocket(this.port); Socket server; while(i < this.maxConnections) { server = listen.accept(); processRequest(server); i++; } processRequest pro...

Problem with Java ThreadFactory

IN my app I use a threadpool with a custom ThreadFactory. My code looks like: pool = Executors.newScheduledThreadPool(10, new TF()); class TF implements ThreadFactory { AtomicInteger count = new AtomicInteger(1); public synchronized Thread newThread(Runnable r) { Thread t = new Thread(r) ; t.setName("ThreadPool...

Java HashMap indexed on 2 keys

I want to create a HashMap in java for users with preferences. This would be easy to do in a database, but unfortunately I can't use a database. What I need is a way to find a user by name in the HashMap, and to find all the users with a certain interest (e.g. golf). If I delete a user, then all their interests should be deleted. Anyon...

Too Many Files Open error in java NIO

Hi I have created a socket and client program using java NIO. My server and client are on different computers ,Server have LINUX OS and CLIENT have WINDOWS OS. Whenever I have created 1024 sockets on client my client machines supports but in server I got too many files open error. So How to open 15000 sockets without any error in server....

How to get data from the velocity page in a action class?

How to get data from the velocity page in a action class? ...

get login username in java

How can I get the username/login name in java ? I tried: try{ LoginContext lc = new LoginContext(appName,new TextCallbackHandler()); lc.login(); Subject subject = lc.getSubject(); Principal principals[] = (Principal[])subject.getPrincipals().toArray(new Principal[0]); for (int i=0; i<principals.len...

What is switch action & forwardAction in struts

What is switch action & forwardAction in struts ...

What is a good standard metric for stability in a web application?

We currently facing some stability issues with our develop web application product. This product was built in part by our partner contractor, and we want to have a good standard metric for stability. The issues we have been facing is constant crashing. The web application is unable to identify when there are more request than it can h...

How do I customize all the names of the child threads of a ThreadFactory in Java?

If I am extending an existing ThreadFactory implementation, how would I go able ensuring that all threads created would have the same prefix? I'm sick and tired of looking at Thread-9 in my logs and would like to distinguish between threads more easily. Does anyone have any suggestions as to how to go about this? ...

dynamically change spring beans

hi, how do I dynamically change the properties of a bean at runtime using java spring? I have a bean mainView, which should use as property "class" either "class1" or "class2". This decision should be made on base of an property-file, where the property "withSmartcard" is "Y" or "N". ApplicationContext: <bean id="mainView" class="m...

What is the exact meaning of static fields in Java?

I would like to share an object between various instances of objects of the same class. Conceptually, while my program is running, all the objects of class A access the same object of class B. I've seen that static is system-wide and that its usage is discouraged. Does that mean that if I've got another program running on the same JVM ...

gwt socket connections

hi, I am trying to write an application that uses java.net.Socket. I have also written an app in Java using GWT to display the contents from an ArrayList. However, I now need to populate that ArrayList via a socket connection. Apparently Google Web Toolkit does not support socket connections. Can anyone please give me a workaround f...

Foreign key is also part of the primary key

Is it possible in plain JPA or JPA+Hibernate extensions to use a foreign key that is also part of the composite primary key? @TableGenerator(name = "trial", table = "third", pkColumnName = "a" , valueColumnName = "b", pkColumnValue = "first") @Entity public class First{ @Id @GeneratedValue(strategy = GenerationType.T...

How can i get checkbox values from struts2 checkbox in displaytag to action class.

I am working on struts2 application in which i am using displaytag for pagination support. Now i want a check box for each row in the table for that i am doing this. <display:table name="countryList" export="true" class="table" id="countryList" pagesize="${selectedPageSize}" decorator="org.displaytag.decorator.TotalTableDecorator...

Java: Resetting all values in the program

Hi, I am working on this program where at the end of the game I ask the user if they want to play again. If they say yes, I need to start a new game. I made a restart() method: public void restart(){ Game g = new Game(); g.playGame(); } However when I call this method some of the values in my program stay at what they were d...

Transfer a file through UDP in java

I have the following algorithm implemented in Java which uses TCP/IP: -Client request a file -Server checks if the file exists - if do: send contents of the file to the client - if not: send "file not found" msg to the client Now I`m having trouble implementing that using UDP Datapackets. Here is my code: CLIENT: package br.c...

Classpath issue using XPathFactory

I keep getting the following exception on one of our live servers (the others running the same code seem ok): java.lang.RuntimeException: XPathFactory#newInstance() failed to create an XPathFactory for the default object model: http://java.sun.com/jaxp/xpath/domwith the XPathFactoryConfigurationException: javax.xml.xpath.XPathFactoryCon...