File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes How to compile/run Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to compile/run" Watch "How to compile/run" New topic
Author

How to compile/run

Vincent Hendriks
Greenhorn

Joined: Oct 19, 2010
Posts: 16
Hi,

Since I recently started learning Java, I'm compiling and running my programs with two batchfiles (because actually working from the command line is not optimal).

I need the compiling batch-file because the window closes so fast after compiling, I can't read the compiler errors (hence the pause!):

@echo off
fileName.java
pause


I need the running batch-file because just double-clicking my class file doesn't work:

@echo off
java fileName
pause


Although this works, it's a bit annoying that I have to change the batch-files everytime I want to compile or run another class...

I'm a bit hesitant though about downloading programming software without knowing what it actually can do...
I don't want to use a big "suite-like" program because the fun for me is not so much in making a big fancy program but in writing the code itself!

Therefore the question: is there another way/a program to do this?
What I could really use is just a code-editor with a compile and a run button and a frame to display compiling- (and yes, I'm a newbie, runtime-) errors (and without fancy extra's, options, etc.)
Kevin Workman
Ranch Hand

Joined: Sep 28, 2010
Posts: 151
Why don't you want to use the command line to compile and run? It really is the best way for newbies to learn.

There are a ton of IDEs out there that do exactly what you just described. Google them, try a few out, and see what you like and don't like.
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3068
    
  33

Try Notepad++. I had long back written an article on how to compile and run java programs through Notepad++ (it was for simple programs, not the one with packages and all).

There should be some way to pass the class name/source file name as the arguments to the batch file- like we have in a shell script. You could try that.


Mohamed Sanaulla | My Blog
Vincent Hendriks
Greenhorn

Joined: Oct 19, 2010
Posts: 16
OK. Good to know that stuff like that is around

I'll try and find something that works for me.

Thanks
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38509
    
  23
You are probably better off at a beginner's stage using the command line directly. Use Notepad++ as a text editor; it is really good for editing program text.
You never double-click a class file to run it.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How to compile/run