Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

How do you run Java Puzzle Ball ?

9a14f127-8560-49af-a391-1434f9fe7f39Apr 27 2017 — edited Oct 30 2019

I've downloaded the JavaPuzzleBall jar file and now I'm trying to run it.

I've tried

java -jar JavaPuzzleBall.jar

java -cp JavaPuzzleBall.jar  javafxapplication01.JavaPuzzleBall

I've tried extracting the contents of the jar file into a directory and then, from this directory, running

java -cp .  javafxapplication01.JavaPuzzleBall

I've tried all the above using -classpath instead of -cp

In all cases the response I get is

Error: Could not find or load main class javafxapplication01.JavaPuzzleBall

I can see the JavaPuzzleBall.class file in the jar file in the correct location and when I extracted the contents it was there in the javafxapplication01 directory.

I've downloaded the jar file three times in case it had been corrupted, but still the same result.

Any ideas what the problem may be ?

Stuart

Comments

843793
I can't remember exactly how it works, but I'm pretty sure you won't be allowed to compile code that breaks genericity.

Remember, a generic class provides genericity, but you provide the parameter. The only situation that breaks this is if member variables are public - which they shouldn't be.
843793
Hi,
According to the GJ specification, the compiler does store extra parameter information in the class files. There is a process called 'retrofitting' which allows to add this extra information to existing classes.
The Java 2 Collection classes which come with the generics compiler were retrofitted in this way. If, however, you use the 'raw types' it is possible to compile code which violates type constraints, and which will fail only at runtime (the compiler will give an unchecked warning, though).
843793
No its not a limitation but the nature of late binding. Sure you can use a precompiled class like it were a library and access the methods directly since you will know what the signatures are. You are within your rights to create as many illegal casts as you want. The point is Generics will not itself create any bad casts. Nobody can stop a mad programmer...
1 - 3

Post Details

Added on Apr 27 2017
9 comments
1,920 views