• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Just getting started, need help

 
Jake Deed
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok so ive installed the Java Development Kit and Runtime Environment and have set the path up correctly for javac.

I made MyFirstApp.java in a folder on my desktop called JAVA. Is this where i should be doing it?

Secondly when i do javac MyFirstApp.java no class file is created. Also when i drag my file onto the javac.exe no class file is created. or atleast i have no idea where it is being sent to.

Can someone please help me, would be much appreciated!
 
Juva Yuva
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did it thrown any error ? can you elaborate the output of javac as seen when executed
 
fred rosenberger
lowercase baba
Bartender
Posts: 12143
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) you can put your .java files anywhere you want - it doesn't matter. it's a bad idea to mix your own .java/.class files with the ones that come with the JDK, but you're not doing that, so you're ok.

2) when you say you "do javac MyFirstApp.java", what DOES it do? tell us EXACTLY what it says. Where are you when you do it (i.e. what directory are you in, what EXACTLY is the command you type, etc). The more details you give, the easier it is to help. Otherwise, we're just kind of guessing.

3) When you say "when i drag my file..." WHAT file are you dragging?

Generally, java doesn't work by 'dragging a file onto the java.exe'. Once you get your .java file to compile into a .class file, you would then run something like the following:

java <classname>


So, if I wrote a class called HelloWorld.java, I would compile it with this:

javac HelloWorld.java


That should create a file called "HelloWorld.class" in the same directory with my HelloWorld.java file. I would then run

java HelloWorld
 
Campbell Ritchie
Sheriff
Pie
Posts: 49367
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have, I am sure, found the Java Tutorials. That section includes instructions about how to execute your first ever program, and also a section about what commonly goes wrong.

And welcome to JavaRanch
 
Jake Deed
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do i get the screen to pause when i do javac MyFirstApp.java in run? it only flashes then dissapears. So i dont see any errors etc.
 
subhajit paul
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
type cmd in run prompt. when the shell opens, type javac <javafilename>.java.

the output/error messages will now be persistent. kindly read them carefully and post in details what error you are coming up with.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12143
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Again, the DETAILS are critical. HOW ARE YOU RUNNING THIS? Are you using an IDE or not? The more details you can give, the easier and sooner someone can help you.

We can assume you are running some flavor of windows. Go to the start menu, and click on 'run'. in the box, type "cmd", then hit enter. Now, navigate to the directory where your .class file lives.

Once there, type "java <classfilename>".
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic