Ken Austin

Ranch Hand
+ Follow
since Aug 20, 2012
Ken likes ...
Firefox Browser Java
Daphne, AL
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Ken Austin

I never did get this program to run, but I did get a similar test program from the textbook that I'm using by installing Maven.

I would prefer not to use Maven or an IDE and just do everything on the command line, but I never figured out how to install JavaFX in such a way that I could do that.
5 days ago
I'm trying to get a JavaFX program to run in Eclipse. After doing some research, I think I got the JavaFX user library configured correctly. It took a lot of Google searches to finally get to the point where the import statements didn't get flagged.

Under Run Configurations, I have this for the VM arguments: --module-path C:\Program Files\openjfx-14.0.1_windows-x64_bin-sdk\javafx-sdk-14.0.1\lib --add-modules=javafx.controls,javafx.fxml

When I try to run the program, I get the error below. As you can see, that is the location where I placed the JavaFX files, and there isn't a main  class there.

Error: Could not find or load main class Files\openjfx-14.0.1_windows-x64_bin-sdk\javafx-sdk-14.0.1\lib
Caused by: java.lang.ClassNotFoundException: Files\openjfx-14.0.1_windows-x64_bin-sdk\javafx-sdk-14.0.1\lib

Screenshots attached.

What are my next steps on this one? Why does Eclipse think I need a main method in the location where the JavaFX files are stored?
6 days ago
I successfully installed Maven on my computer.

I saved the sample pom file and the files to the directory where I've been doing all of my coding.

When I ran the command from the website "mvn clean javafx:run", I go the following error:

[ERROR] Failed to execute goal org.openjfx:javafx-maven-plugin:0.0.3:run (default-cli) on project hellofx: Error: Output directory is empty, compile first -> [Help 1]

When I tried to compile, I got multiple errors. Here are the first five: error: package javafx.application does not exist
import javafx.application.Application;
                        ^ error: package javafx.scene does not exist
import javafx.scene.Scene;
                  ^ error: package javafx.scene.control does not exist
import javafx.scene.control.Label;
                          ^ error: package javafx.scene.layout does not exist
import javafx.scene.layout.StackPane;
                         ^ error: package javafx.stage does not exist
import javafx.stage.Stage;

What is my next step? (By the way, I tried manually placing the JavaFX files in the directories specified by Oracle and that didn't work.)

1 week ago

That did it. I changed the average type to a double and that solved the problem. I can't believe I missed that.

Thank you so much.

2 weeks ago
I'm trying to do a cast from an to a double on line 40, and I can't figure out why it isn't working. The error messages seems to indicate that I am trying to convert a double to a float, but that's not the case.

I've Googled casting and my cast appears to match all of the examples that I've seen, including the example program from the text.

What am I missing that is causing the cast to fail in my program? Can someone give me an assist?

Error: error: incompatible types: possible lossy conversion from double to float

What do I need to do to get that working?

2 weeks ago
You're probably right.

Since I am starting from scratch (again), I thought it might be a better idea to learn how to do everything manually before I moved to Maven and an IDE. However, it would get me over this hurdle.
2 weeks ago
Per Oracle, the default location for JavaFX is here:

For Mac OS X. The default installation directory is /Library/Frameworks/JavaFX.framework/Versions/ version-number.

Should I be okay manually moving those files to that location? Does anything else need to get done?
2 weeks ago
Greetings, everyone.

I've downloaded JavaFX for Mac to my computer from the Gluon website, but it doesn't come with an installer. It's just a zip file full of files.

In Oracle's instructions for installing JavaFX on a Mac, it mentions an installer, so I went back to make sure that I downloaded the correct package, and it appears I did (javafx-sdk-14.0.1). There's no installer in there.

What are my next steps for getting this installed? Manually copying them to the right place? Where would that be on a Mac?

2 weeks ago

Thanks for the further explanation. That helps.

The TextIO class comes from the free online Javanotes text book by David J. Eck. I really like the book.

TextIO is designed to make input and output easier for greenhorns.

Here's the link to the book's website:

2 weeks ago
That did it. Thank you.

In the YouTube video where the guy solved the issue, both of his files were in the same folder. I never would have thought to try this.

Is that a general rule that I will need to follow from now on? All imports that aren't part of Java will need to be in their own individual folders with the folders named for the files inside them?
2 weeks ago
I have done my homework on this one, and it still eludes me.

For fun, I am working through Javanotes by David J. Eick.  To ease the difficulty of text input at the beginning, he provides a class called TextIO that comes as a separate file.

After referring to some posts on Stack Exchange which were mostly over my head, and the Understanding the class path and package names documentation in the Oracle docs, I was still lost.

Finally I found a YouTube video where a guy resolved the problem I was having by changing the CLASSPATH, which I did, but I am still getting the error that the TextIO class does not exist.

The TextIO class file is in the same directory as the project that I am compiling, and I am in the correct directory when I try to compile.

After reading a post here on Code Ranch, I tried changing the CLASSPATH to the directory just above the one with the files, but I got the same error.

I'm using Sublime Text for my text editor, and am trying to compile via the command line in the Terminal window of an old MacBook Pro. Java Version 14.0.1.

Also, this is the first program that I haven't been able to get to compile and run, so things should be set up correctly.

2 weeks ago
I'm going to sleep on this one and try again in the morning. Something like...

Junilu Lacar wrote:

Ok, now that you've seen what wonders Extract Method can do for your code's readability, what expression(s) can you extract from the section of your code quoted below to make it more readable? Hint: an intention-revealing name such as isOutOfBounds() is almost always better than a comment. Comments tend to get ignored whereas you always pay attention to a method name.

You'll probably go for the easy win and extract the conditional expressions of the if statements but see what you can do to clarify and generalize the intent of the statements inside the if statements because those look like they could use a little DRYing out.

7 years ago
Yes, perc.N works, so I yanked the get method out. Thanks for that tidbit.

Junilu Lacar wrote:You probably tried to just reference N directly, right? Did you try perc.N? If you keep the N name, that might be a compelling reason to provide a better-named accessor like getSize() or getGridSize(), even if it only just returns the value of N directly.

Edit: I was looking at your use of getN() again and realized that you don't even need access to N. Just print out GRID_SIZE -- that should be the same as N anyway. If it isn't, then you'd have a bug.

7 years ago
So the private method would be a good place for an assert statement, rather than the bounds checking?

Junilu Lacar wrote:I noticed that you are doing bounds checking in a private method. Bounds checking should be done in methods that are part of the class API, that is, any method that can be called by someone else and you have no way of controlling the validity of the values being passed in. There should be no need to do bounds checking in private methods since you have control over the calls made to it. If an exception occurs because out of bounds values have been passed to a private method, that's either a bug or a lack of bounds checking in the calling method.

7 years ago
Junilu, thanks for your helpful comments.

I agree that N is not very descriptive. That was the nomenclature used in the programming exercise description of the API, and I guess I assumed they wanted us to leave it as it it was.

I added isOutOfBounds(n) to the original. That makes it a lot easier to read.

I made N final. That makes good sense.

The reason I added the getN() method was because I wasn't able to access it from main() because it was non-static. Was that not the right way to handle that? Should I have made it static instead?
7 years ago