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 trialChristina Vieau
679 PointsJShell not finding file, I am in the PezDispenser.java file but the console is giving an error message.
treehouse:~/workspace$ /open PezDispenser.java
bash: /open: No such file or directory
It worked yesterday but had to stop and finish this task today and now it does not find it. Above is the message I am getting. I am in the JavaObjects folder with that particular file open. I did try compiling the file and running it in the console but I received this error message.
Picked up JAVA_TOOL_OPTIONS: -Xmx128m
Picked up _JAVA_OPTIONS: -Xmx128m
Picked up JAVA_TOOL_OPTIONS: -Xmx128m
Picked up _JAVA_OPTIONS: -Xmx128m
Error: Main method not found in class PezDispenser, please define the main method as:
public static void main(String[] args)
or a JavaFX application class must extend javafx.application.Application
I believe it is asking me to put my file under the public static void status but I do not want to alter the code since I am trying to copy the class example exactly. I would copy the code I have written but I do not see a copy option in the edit drop down menu of workspace. Any help would be greatly appreciated. Thank you.
2 Answers
Simon Coates
8,377 PointsI'm a little confused. Your initial comment seems to be about using jshell, but you're seemingly running the /open command at a standard terminal prompt. If inside jshell, you'd probably have a prompt that reads "jshell>".
The second part seems to be the console telling you that you don't have a main method. A method with a signature of "public static void main(String[] args)" is necessary for java to run anything. If you could confirm that you have one, have saved and recompiled.
Christina Vieau
679 PointsHi Simon, You are correct to be confused. After I got my initial error message I tried to compile and run the file in jshell. I did eventually figure that out and once I got back to workspace and compiled and ran the file jshell did not give me an error message. Thank you for your response, you were on point. Christina