Welcome! Log In Create A New Profile


Compling Java Source Code

Posted by robbiepapenfus 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
Compling Java Source Code
March 18, 2008 10:59AM
Hi there,

If you look of page 66 of the textook, point 2 (Compiling the Java Source Coce). Where do you actually type: venus% javac Hello.java to compile the program? Any ideas? (2008-03-17 21:35)

Re: Compling Java Source Code
March 18, 2008 01:55PM
once you completed ur program.
in command propmt type in :

javac Hello.java
avatar Re: Compling Java Source Code
March 18, 2008 02:29PM
You must type javac Hello.java in the command prompt.

Follow the instructions on the CD to setup your computer.
Re: Compling Java Source Code
March 20, 2008 11:25PM
to make life easier permanently set environment variables under system properties,advanced then click the environment variables button at the bottom
Re: Compling Java Source Code
May 04, 2008 07:23PM
Here are some tips that might just save you the 4 hours I lost.

When compiling a standard file, use the following:
javac [filename].java

When you are compiling a file that will be used by other files/classes, (import statements) use the following
javac -d . [filename].java
** The dot will save you the hassle of typing in the whole folder structure.

When compiling a file that uses other files, first compile the files with the aforementioned command, then execute the following
javac -classpath . [filename].java
** This works if all the java files are in the same folder, I have not tried to compile with java files in various folders.

Lastly, if you file uses other files, and will be used by other files, use the following
javac -d . -classpath . [filename].java

Now that you have compiled your code, and you have a happy grin on your face, use the following to execute the code:
java [filename]
just enter the file/class name, eg Student, not Student.class. if you add the .class extension, java complains, and you get all sad. sad smiley

A really useful bit of code to add to your classes, while you are testing:
**this will stop the application and you can view output before you continue, by pressing enter.

I hope this post is helpful.
avatar Re: Compling Java Source Code
May 04, 2008 07:44PM
Or you can get Netbeans and use your time to code? smiling smiley

just my 2c worth....
Re: Compling Java Source Code
May 06, 2008 07:00AM
Or eclipse...

I am using Notepad++, as I am trying hard to remember the syntax of Java. It is annoying when you get C++, Java and C# confused.

Notepad++ is a brilliant little text editor, with some stunning add-ons that makes is very useful! Definitely worth the download.

Sorry, only registered users may post in this forum.

Click here to login