.java on JavaFiddle

Hi, thanks for the great tools that you guys are building. Is it possible to create classes in .java files in the javafiddle and run the code? Could someone give me an example? Thanks
10 Replies
apignotti
apignotti3mo ago
Hi and welcome to the community. Can you clarify what you are trying to achieve? JavaFiddle compiles .java files and runs them in the browser exactly as you describe.
apignotti
apignotti3mo ago
Java fiddle is open source as well, so you can take the code as an example: https://github.com/leaningtech/javafiddle
GitHub
GitHub - leaningtech/javafiddle: Build, run, and share Java snippet...
Build, run, and share Java snippets in the browser - leaningtech/javafiddle
DevDude
DevDudeOP3mo ago
wow, thanks for the quick reply. I am trying to create a class and use that in Main, however I get the error that the class needs to be in a file with the same name ending in .java so I am wondering if there is an example for such a case that works.
apignotti
apignotti3mo ago
I am sorry I am still unsure about what you trying to achieve exactly? Are you using our JavaFiddle or are you trying to make your own? Can you share logs or screenshot to help us understand?
DevDude
DevDudeOP3mo ago
on https://javafiddle.leaningtech.com just adding a new file for a new class and trying to use that from main
JavaFiddle - Build and share Java code snippets in your browser
JavaFiddle is an online, browser-based Java IDE. Create and share Swing applications for free!
DevDude
DevDudeOP3mo ago
OK I figured out, the issue is about changing file names in the tabs Thanks for the confirmation that it should work
apignotti
apignotti3mo ago
👍 I'll also ask the team to rename the created classes. Class is a very bad choice.
DevDude
DevDudeOP3mo ago
true, it is confusing, but also rename working could reduce confusion 😎
apignotti
apignotti3mo ago
That is a non obvious problem since the class name can be used in many places and in many ways Out of scope for a demo like JavaFiddle
DevDude
DevDudeOP3mo ago
From UX perspective maybe it would be good enough to not allow rename and show a cheep alert or something. would have saved you some time with me 😀

Did you find this page helpful?