• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Running compiled java code

 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI
Yesterday I successfully wrote and compiled some code. It is a window that opens up and says hello java. Where is this code? How do I run the code? What extension do I click on to run the code.
Mark
 
Saloon Keeper
Posts: 7389
170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How did you compile the code? From the command line or from an IDE?
 
Master Rancher
Posts: 4833
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What OS are you using?
Do you want to be able to execute the program from outside of the IDE?

This thread looks like a continuation of this: https://coderanch.com/t/753358/java/Java-ide
 
Sheriff
Posts: 6964
2
Eclipse IDE Debian Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This seems like a follow-up from some of your previous posts.

Have you run your code from Eclipse using "Run As" as I suggested in the other threads? Does it produce the expected output?

The Java compiler compiles your Java source code to "class files" which have the same name as the source file but with the ".java" replaced by ".class". In most cases you cannot simply run these class files, as they are not a native executable file for your operating system (such as an exe or app file)

To  run a java class file you need a Java Virtual Machine (JVM). If the Java tools are in your command path, you can run a java class file using the "java" command.

This is very limited, though. Real -world Java applications consist of many class files produced from many Java source files. Such applications are usually bundled into a ".jar" file, which can also be run using the "java" command, and may also be recognized as an executable type by your operating system. Creating such an "executable jar file" is an advanced topic.

As I said before in a different thread, you should develop, run, and test your code in your IDE of choice until you are happy that it does what it needs to do, and only then export it as a jar file so it can be run separately.

So I ask again: Have you run your code from Eclipse using "Run As" as I suggested in the other threads? Does it produce the expected output?
 
Mark Roberge
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Norm Radder wrote:What OS are you using?  Windows 11
Do you want to be able to execute the program from outside of the IDE?  I  prefer to use an IDE

This thread looks like a continuation of this: https://coderanch.com/t/753358/java/Java-ide


No it is not. Different topic.
 
Mark Roberge
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Frank Carver wrote:. . . Does it produce the expected output?[/b]

 Yes it does!
 
Norm Radder
Master Rancher
Posts: 4833
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Yes it does!


Has your question been answered now?
If not, please explain what you are trying to do.

If you have questions about how to use Eclipse, try asking here: https://coderanch.com/f/180/eclipse
 
Mark Roberge
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm good thanks
 
reply
    Bookmark Topic Watch Topic
  • New Topic