java-7

Cannot find main class on Linux - Classpath issue

一曲冷凌霜 提交于 2019-12-04 06:12:56
问题 I am having some trouble running a few jar's on a linux box. Basically, I am getting an error saying it cannot find the main class of my main jar. The class is defenetly present so it must be a classpath issue. I am not great with linux, so I am looking for some advice as to where I might be missing something. First off, I am setting the classpath in the users bash_profile; adding all the jar's required, seperated by a : delimeter. I then export the classpath. Then, in the shell (ksh) script

Efficiently converting java string to its equivalent enum

谁都会走 提交于 2019-12-04 05:33:43
问题 Given a string i want to get the enum equivalent of it in constant time. I have a enum defined like the one shown in the question. Best way to create enum of strings? public enum Strings { STRING_ONE("ONE"), STRING_TWO("TWO") ; private final String text; /** * @param text */ private Strings(final String text) { this.text = text; } /* (non-Javadoc) * @see java.lang.Enum#toString() */ @Override public String toString() { return text; } } If i now get a string (say "TWO"), is there a way to see

Use String hashCode() Method? [closed]

对着背影说爱祢 提交于 2019-12-04 05:30:28
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 6 years ago . From link : http://www.tutorialspoint.com/java/java_string_hashcode.htm Relationship between hashCode and equals method in Java Good hashCode() Implementation But i cant understand about the hashcode . Here's an example: public class StringDemo { public static void main(String args[]){ String

Difference between Objects.hashCode() and new Object().hashCode()?

杀马特。学长 韩版系。学妹 提交于 2019-12-04 04:27:41
问题 What's the difference between these two code snippets? Snippet 1: Object o = new Object(); int i = Objects.hashCode(o); Snippet 2: Object o = new Object(); int i = o.hashCode(); 回答1: Tolerates null value The only difference is that if o is null, Objects.hashCode(o) returns 0 whereas o.hashCode() would throw a NullPointerException . 回答2: This is how Objects.hashCode() is implemented: public static int hashCode(Object o) { return o != null ? o.hashCode() : 0; } If o is null then Objects

java 7 directory monitoring questions

萝らか妹 提交于 2019-12-04 04:07:42
I just saw an awesome feature with java 7, the directory watcher. It'll tell you when something changed in a directory without polling the directory. 1.) But it says it falls back to polling if the filesystem doesn't support registering for change events. Do all typical linux and windows filesystems(extX,ntfs,reiserXXX,jsf,zfs) support this feature? 2.) Is renaming a file inside a directory a create or a change event? Or is that one delete and one create? I can test it on one system, but will it then be the same for all filesystems? It looks like you're talking about the WatchService . The

Java JDK 8 IndexedPropertyDescriptor has changed since JDK 7 with List object

懵懂的女人 提交于 2019-12-04 04:04:24
I have a simple issue. I have a program working in Java JDK7 but it doesn't work in JDK8 because of some introspection changes. Here is a test program to reproduce the issue: import java.beans.BeanInfo; import java.beans.IntrospectionException; import java.beans.Introspector; import java.beans.PropertyDescriptor; import java.util.ArrayList; import java.util.List; public class Main { public static void main(String[] args) throws IntrospectionException { BeanInfo info = Introspector.getBeanInfo(MyListClass.class); PropertyDescriptor[] descriptors = info.getPropertyDescriptors(); for (int i = 0;

Java - How do I get a all the selected values from a JList?

纵然是瞬间 提交于 2019-12-04 03:44:34
A struggling Java newbie here - help! I'm trying to: - Get all the selected values from a JList - Create an ArrayList from those values It seems getSelectedValues is deprecated? Until JDK 1.6 (deprecated in 1.7): public Object[] getSelectedValues() New since JDK 1.7: public List<E> getSelectedValuesList() Returns a list of all the selected items, in increasing order based on their indices in the list. As of JDK1.7 it was replaced with public List<E> getSelectedValuesList() . http://docs.oracle.com/javase/7/docs/api/javax/swing/JList.html#getSelectedValuesList%28%29 use getSelectedValuesList

JAX-WS HTTP logging in Java 1.7

倾然丶 夕夏残阳落幕 提交于 2019-12-04 03:39:01
I am using JAX-WS as a client. I used to use the following system property to log all HTTP requests & responses for debugging: com.sun.xml.ws.transport.local.HTTPTransportPipe.dump=true However, since upgrading to Java 1.7 and using the built-in JAX-WS (instead of the external libraries) this functionality has stopped working. I have done a lot of searching to find what the equivalent properly is in 1.7 but have had no luck. Does anybody know how to log the output? Thanks for any help Try com.sun.xml.ws.transport.http.client.HttpTransportPipe.dump=true EDIT: Ok, try com.sun.xml.internal.ws

JSR-356: How to abort a websocket connection during the handshake?

扶醉桌前 提交于 2019-12-04 02:59:42
问题 I need to be able to abort a websocket connection during the handshake in case the HTTP request does not meet certain criteria. From what I understand, the proper place to do that is inside the ServerEndpointConfig.Configurator.modifyHandshake() method of my own Configurator implementation. I just can't figure out what to do to abort the connection. There's a HandshakeResponse parameter which allows adding headers to the response but I couldn't find any header that does the job. So how can I

Using CDI without a Servlet Container

好久不见. 提交于 2019-12-04 02:49:55
I want to write a simple Java Desktop Application using Java Swing. Usually I use Spring Framework to do the dependency injection and build the whole class structure. However, I've seen that CDI is becoming more and more popular and want to give it a try. I would like to do the Dependency Injection of my project using CDI, but I don't know if this is possible without a Servlet container (as it is using Spring). Every single tutorial seems to be related with servlet containers or application servers. You don't need a container: A very short tutorial can be found here: http://randling.wordpress