Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Unable to run Java class
icon11.gif  Unable to run Java class [message #1749347] Mon, 05 December 2016 17:51 Go to next message
Sam Bh is currently offline Sam BhFriend
Messages: 5
Registered: December 2016
Junior Member
Using Jdk8, Win7, eclipse Mars 4.5.0
I have a java class I am able to compile it, I can see the .class file in the /bin folder. But eclipse does not give me an option to run it. Confused I can run all my other files fine. It is a stand alone java class, yes I do have the main method. Tried 'Clean', 'restarted' eclipse, tried to add it to 'organize favorties' - it does not show in the list. Surprised

What can I do?

Thanks
Sam
Re: Unable to run Java class [message #1749433 is a reply to message #1749347] Tue, 06 December 2016 17:10 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
From what you write it's hard to guess what goes wrong. Could be as simple as wrong modifier or signature of main(..), or you're tying a wrong gesture (menu, shortcut etc.) etc.
Re: Unable to run Java class [message #1749434 is a reply to message #1749433] Tue, 06 December 2016 17:26 Go to previous messageGo to next message
Sam Bh is currently offline Sam BhFriend
Messages: 5
Registered: December 2016
Junior Member
Problem was actually an compile issue- was hard for me to guess/see. I would not expect the .class file to get created if there is a compile error. I Kept deleting the .class- to ensure compile issues. But would get recreated again despite compile issue (not at all familiar with this behavior Shocked ).

However I finally got it compiled successfully by doing Maven project import etc. But still cant run. Have posted a separate question on this. Crying or Very Sad

[Updated on: Tue, 06 December 2016 17:35]

Report message to a moderator

Re: Unable to run Java class [message #1749436 is a reply to message #1749434] Tue, 06 December 2016 17:49 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Sam Bh wrote on Tue, 06 December 2016 18:26
Problem was actually an compile issue- was hard for me to guess/see. I would not expect the .class file to get created if there is a compile error. I Kept deleting the .class- to ensure compile issues. But would get recreated again despite compile issue (not at all familiar with this behavior Shocked ).


It's one of the differences between compilers, see, e.g., this answer on StackOverflow

Lesson learned: pay attention to compiler errors reported in the IDE Smile
Re: Unable to run Java class [message #1749437 is a reply to message #1749436] Tue, 06 December 2016 17:56 Go to previous messageGo to next message
Sam Bh is currently offline Sam BhFriend
Messages: 5
Registered: December 2016
Junior Member
Oh well- totally new to me(I am really out of touch), Rolling Eyes
My JAVA_HOME is my installed jdk8 - I would assume eclipse would use that. I will research this at some time.
Re: Unable to run Java class [message #1749628 is a reply to message #1749437] Thu, 08 December 2016 17:43 Go to previous message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Sam Bh wrote on Tue, 06 December 2016 18:56
Oh well- totally new to me(I am really out of touch), Rolling Eyes
My JAVA_HOME is my installed jdk8 - I would assume eclipse would use that. I will research this at some time.


That only means that Eclipse runs on the JVM found in that installation. It doesn't mean that eclipse would be calling the compiler from it. In fact you can run Eclipse on a JRE, which doesn't even contain the javac compiler.
Previous Topic:Prevent "Quick Access" field from displaying commands
Next Topic:How to null annotate Collectors.joining?
Goto Forum:
  


Current Time: Mon Dec 30 14:43:04 GMT 2024

Powered by FUDForum. Page generated in 0.04335 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top