Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java

Joey Kao
Joey Kao
15,875 Points

Cannot run the JavaFX program on the terminal, but it run well on intelliJ.

I am trying to create a JavaFX program. The program run well on intellij. However, when I try to execute “Main.class” on the terminal. I get a NoClassDefFoundError. Can anyone help solve the problem. Thanks!!

My operating system is OS X. My intelliJ version is 15.

Jiří Kolařík
Jiří Kolařík
9,373 Points

You need use command java with parametrs: "cp", information about source floder "src" and information about main package. e.g.: java -cp src com.treehouse.Main

Joey Kao
Joey Kao
15,875 Points

Hi Jiří , Thank you for your reply!! In the class path "src com.treehouse.Main", Does the src means the upper directory and "com.treehouse" the packages?

2 Answers

Jiří Kolařík
Jiří Kolařík
9,373 Points

Yes, "src" is file path where is starting your folder with JAVA packages in your project. The next is path in java package's syntax to main class of project e.g."src com.treehouse.Main". In this example it is run file in file system path: ./src/com/treehouse/Main.class

Joey Kao
Joey Kao
15,875 Points

Hi Jiří, thank you soooooo much!!