• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Bear Bibeault
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • salvin francis
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
Bartenders:
  • Jj Roberts
  • Carey Brown
  • Scott Selikoff

just starting, how to run .java files?

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Im just starting Java, after reading a tutorial, it says i save it as .Java and i should be able to run it... but it opens in notepad.

Im using JCreator (also tried BlueJ, Eclipse and netbeans)

Any help? Thanks.
 
Ranch Hand
Posts: 1847
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You will need to compile them first...

If your tutorial says you can run them directly, get another tutorial.
 
Justin
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have compiled it. Im using the tutorial here: http://www.javacoffeebreak.com/java101/java101.html


my code looks like this:



not sure if the javac and java (last 2 lines) go there or somewhere else, but it doesnt do anything if i remove them also.
[ April 23, 2006: Message edited by: Justin ]
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are supposed to write the lines javac Helloworld.java and java Helloworld in the command line.

javac Helloworld.java compiles your .java file which has your code. It creates a .class file for you.

java Helloworld runs the class file

You must using the command line go to the bin folder in which you have java.exe and javac.exe. You should also have your Helloworld.java file here.
After that you can write those 2 commands in the command line.

You say you use JCreator, never used it but atleast the Eclipse IDE got a button with which you can run your code. Also i hope you got the HelloworldFrame class otherwise that wont compile.
[ April 23, 2006: Message edited by: Jon Mattson ]
 
Ranch Hand
Posts: 490
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jon Mattson:

A good idea is to have your .java file in the same directory where you have javac.exe and java.exe



Pardon, but that is a bad idea. Cluttering up /bin just makes a mess.

Store your java files elsewhere, and outside of the java directory.

Something like C:/projects is much better. Then make a folder inside projects for each individual project. Keep things tidy.
 
Jon Mattson
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Already edited that out
I mean that that is the simplest way to get a program running. You don't need to change any paths and stuff.

Using Eclipse now which solves all problems
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Justin,"

Welcome to JavaRanch!

Please revise your display name to meet the JavaRanch Naming Policy. To maintain the friendly atmosphere here at the ranch, we like folks to use real (or at least real-looking) names, with a first and a last name.

You can edit your name here.

Thank you for your prompt attention, and enjoy the ranch!

-Marc

PS: Putting your own files in the bin directory is a Bad Idea. You don't want to take any chances of messing up what's there.
 
I think he's gonna try to grab my monkey. Do we have a monkey outfit for this tiny ad?
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic