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 Running Book Examples Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Running Book Examples" Watch "Running Book Examples" New topic
Author

Running Book Examples

Roger Fed
Ranch Hand

Joined: Oct 17, 2010
Posts: 82

hello my friends
I've source code files for examples and solution for some exercises of the book that i learn java from .
when i want to run any file of them i have to make a new project and include this file through copy and paste
i feel that is a boring task .
i wonder if any one can give me an easier way than this???
thanks in advance


I Hear I Forget, I See I Remember, I Do I Understand.
Hari r.haran
Greenhorn

Joined: Feb 01, 2011
Posts: 9
Hi,

Could you please tell which IDE you use for running the source code?

Regards,

Hari
Roger Fed
Ranch Hand

Joined: Oct 17, 2010
Posts: 82

I'm very sorry for this
IDE: NetBeans
Hari r.haran
Greenhorn

Joined: Feb 01, 2011
Posts: 9

Hi,

If you don't want to use any IDE, then you could go for manual compilation and interpretation of the code. The following is the set of steps to do so.

1. Create a java file with some name like "Test.java" in java's home directory (Done only for the 1st time)

2. Copy paste the code in the file. If the class code you have, is public, then remove the public modifier in the class declaration and then save it.

3. Open cmd.exe and change to java's home directory. (Done only for the 1st time)

4. Compile using javac Test.java

5. Execute using java className

Afterwards, if you want to execute a new code, overwrite the existing code and save it. Cmd.exe saves all the commands that you type. So you could simply use the up arrow to compile. Only for executing you must just change the className to the new className in the example that you copied.

This might seem very tough, but once you try, it s the basic and the most easiest way.

Thanks and regards

Hari
Hari r.haran
Greenhorn

Joined: Feb 01, 2011
Posts: 9
Hi again,

If you want to use the NetBeans IDE, then just create a java project, and then create a new class file with whatever class name you want, inside the project.

Once you want to try executing a code, you simply copy paste the code in the source file which you have created now in the project. Definitely you will get an error stating that the class name is different from the file name. Since it is netbeans, it will show hints to the right hand side of the error line. Click on that yellow bulb to get a list of error-correction options.

Netbeans would show options for either correcting the class name or the file name. You simply click on the option that changes the file name. After that, you won't get any errors. You can simply do it for all the code you want to try.

Regards,

Hari
Roger Fed
Ranch Hand

Joined: Oct 17, 2010
Posts: 82

Thanks for your help but i want to use NetBeans not command prompt as i seek to use the debugger and
other tools in this IDE
so, I'd be grateful if you can help me in this
Roger Fed
Ranch Hand

Joined: Oct 17, 2010
Posts: 82

Thanks again but you don't fix my problem that i state in main topic
Hari r.haran
Greenhorn

Joined: Feb 01, 2011
Posts: 9
Do you don't even want to copy and paste the code?
Roger Fed
Ranch Hand

Joined: Oct 17, 2010
Posts: 82

I ask about make a directory or something like this
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Running Book Examples