Browsing 7239 questions and answers with Jon Skeet

Java compilation error: could not find or load main class Main

I've tried many configurations and parameter settings, but keep getting Error: Could not find or load main class Main error. Most of the code I've copied from other SO questions...
Jon Skeet
people
quotationmark

I suspect this is the problem: <attribute name="Main-Class" value="Main"/> It should be: <attribute name="Main-Class" value="com.cfsware.osco.test.Main"/> ... in other words, the fully-qualified name of the class. Your... more 9/19/2014 2:45:42 PM

people

What character set does encode the "é" character as 130 in decimal?

I'm doing an example Java application that uses JDBC to extract some data from MySQL. It works bad with the characters á, é, í, ó and ú, when these caracters are in the database...
Jon Skeet
people
quotationmark

I suspect you're looking for IBM code page 437. (There may well be others that encode the same character in the same way, of course.) Whether a particular Java implementation knows about it or not is very implementation-specific though...... more 9/19/2014 1:08:52 PM

people

IEqualityComparer for Annoymous Type

Firstly I have seen IEqualityComparer for anonymous type and the answers there do not answer my question, for the obvious reason that I need an IEqualityComparer not and IComparer...
Jon Skeet
people
quotationmark

Is there a way I can create my an IEquailityComparer for my anonymous types? Sure. You just need to use type inference. For example, you could have something like: public static class InferredEqualityComparer { public static... more 9/19/2014 12:59:46 PM

people

LINQ to Entities does not recognize the method Double Round(Double, Int32, System.MidpointRounding) method

I've tried the below LINQ Query in Linqer it is working fine but it is giving the below error while i tried with C# from IHeal_Mnt_Tickets in iHealEntities.iHeal_Mnt_Tickets ...
Jon Skeet
people
quotationmark

Not everything that's supported in the BCL has a direct equivalent in SQL. Given that this is the final part of the query, the simplest approach would be to just write a query which fetched all the data you need without rounding etc, and... more 9/19/2014 12:30:35 PM

people

Class inheritance and retrieval

first time i'm playing around with class inheritances etc but i'm a little confused with how I retrieve the information that I set. I've a class called ClientInfo, in that class...
Jon Skeet
people
quotationmark

You would need to cast the result of list.get(0) - the compiler is complaining because List<ClientInfo>.get(...) will definitely return a reference to a ClientInfo-compatible object (or null), but it might not be a... more 9/19/2014 10:13:55 AM

people

Return the number of elements in a linked list recursively

I have the following recursive method in a class called ImageNode which is passed the head(this - the start of the linked list) from a class called Image. I thought my code would...
Jon Skeet
people
quotationmark

You're ignoring the result of countRec() - and you're iterating within the recursive call, defeating the purpose. (You're also making a recursive call on the same object, with no parameters and no change in state... so that can't do any... more 9/19/2014 6:19:03 AM

people

Return a value from paralell stream? java

I have a method that uses parallelStream to run through an ArrayList of objects checking for collisions, however I'm not sure how to return a value from this sort of lambda...
Jon Skeet
people
quotationmark

If you're just trying to check whether any value matches the predict, you can use anyMatch: Returns whether any elements of this stream match the provided predicate. May not evaluate the predicate on all elements if not necessary for... more 9/19/2014 6:07:44 AM

people

Will an inner class get GC'ed if enclosing type reference is maintained?

To me it seems obvious that it wouldn't get maintained, but I've bee fooled before by subtle features of java, like providing a reference to an enclosing type by parameterizing...
Jon Skeet
people
quotationmark

Yes, the instance of the inner class will be eligible for GC. The inner class instance has a reference to the instance of the containing class instance, not the other way round. more 9/18/2014 2:09:20 PM

people

Google Calendar V3 hangs when used outside local environment

I'm working on a wrapper for the .net version of the Google Calendar API. The authentication is rather simple and working fine locally (localhost:port). UserCredential...
Jon Skeet
people
quotationmark

I suspect the problem is that you're using AuthorizeAsync(...).Result. Using the Result property blocks the current thread... and I suspect that ASP.NET is trying to schedule the continuation (when authentication completes) in the same... more 9/18/2014 1:58:30 PM

people

incompatible types required: Class<T> found: Class<CAP#1> where T is a type variable

The following code: public class A<T> { Class<T> klass; T instance; public A(T instance) { this.klass = instance.getClass(); // this requires an...
Jon Skeet
people
quotationmark

Why isn't the compiler satisfied that instance.getClass() will always produce Class (since instance is of type T) and requires an explicit cast instead? Consider this: A<Object> a = new A<Object>("Foo"); Calling... more 9/18/2014 1:39:37 PM

people