1.

Solve : JAVA Programming (Platform)?

Answer»

I have done programming in dBaseIV, Access and VB. In these programming languages I was using programing platforms like Dot Prompt and design screens. However, now that am learning programming in Java I have installed the software but I cant see the platform except receiving massages that the software is installed.

Please let me know where I can test Java programming codes....Hello there EK.

To develop and test programs in Java (source code), you have to download the Java Development Kit (JDK, formerly referred to as JavaSDK (Software Development Kit)).

Download it here.
Scroll a bit down and you will find JDK 6 Update 18 (JDK or JRE), which is the JDK you need.

There are two steps required:

I. Compiling your code (.java)

If you installed the JDK, you will find the (javac.exe) javac executable (compiler) under the default directory of the JDK (usually c:\jdk, otherwise it will be in the JDK installation dir you put it in; please install the JDK in a seperate directory than the JRE dir).
This (javac) is what you need to compile your files (before you can run them of course).

.java is the code, .class is the compiled file (e.g. HelloWorld.java -> javac -> HelloWorld.class).
To test your code, you need to compile the .java file, which is why I was explaining the previous.

In short, download the JDK, locate the javac.exe, go to Windows commandline and run the following:

cd x:\path\to\jdk\

Commandline will now display:
x:\path\to\jdk

To compile, run the following (assuming that javac.exe is in this dir):
javac x:\path\to\yourfiledir\test.java

After it has been compiled (when it's compiled, commandline will return to default prompt),
the file will reside in x:\path\to\yourfiledir\, named x:\path\to\yourfiledir\test.class

By default, the compiler puts each class file in the same directory as its source file. You can specify a separate destination directory with -d (e.g. javac -d


II. Running your code (.class)

You can test your code in 2 ways.

1. Commandline-wise, through the java.exe executable (usually found in C:\WINDOWS\system32 ;this path has been added to Path in the environment variables, so all you have to do to run your .class program is to open up Windows commandline and run the following command:

java -cp x:\path\to\yourfiledir yourfile

java.exe will assume that yourfiledir is the directory to search for the particular yourfile.class java class thanks to the -cp (classpath; absolute directory) command.
It will also assume that yourfile translates to yourfile.class, so don't specify the .class extension in the command.

2. IDE-wise, comes with GUI Text Editor, compiler, debugger, everything.
Two popular ONES are IntelliJ and NetBeans (others are JBuilder, etc. etc.)


Good luck.
If any questions, you may post them here.

Treval


Hi Treval!

Have just seen your massage... am following the steps will post you how it goes...

Thanks
EKAlright man.
I'll read about it when you post it.

Treval
Hi Treval!

I have problems understanding your syntax. (cd x:\path\to\jdk).

I have done the following:

1. Downloaded Java JDK13
2. Installed it in c:\jdk
3. Located javac.exe that its in C:\jdk\bin
4. ................

Your notes are confusing me. I don't know if am suppose to copy the javac.exe file to c:\jdk\ or am suppose to run the javac.exe before I come to compile my programs.

Pls help.

EdgarHm. Sorry if I confused you.

- The syntax 'cd' is for Windows commandline ('DOS'), which means 'change directory'.
- 'x:' is a general representation of your drive (for EXAMPLE, it can be c:), so REPLACE x: with the drive letter
of your drive.
- path/to/jdk is yet another generalisation of your path. It is just illustrating the path to the jdk (so you have to replace 'path/to/jdk' with 'c:\jdk\bin' for example)

javac is the compiler. You need it to compile your .java written code before you can run it.

The steps are as usual:

1. Write your java program in notepad
2. Save as myprogram.java
3. Open up Windows commandline (DOS) and type cd c:\jdk\bin then press enter
4. The commandline should now SHOW "c:\jdk\bin>" with a blinking cursor
5. To compile your java program, have javac compile it by passing the path of your
java program to the javac compiler with the -cp or -classpath (classpath) switch.
Here is how you do it:
If your .java program you've just written resides in c:\Edgar\java\myprogram.java, then write this in commandline as the following step:
javac -classpath c:\Edgar\java\myprogram.java
6. To run your java program that you've just compiled, write the following in commandline:
java -classpath c:\Edgar\java\myprogram

That's it!
If my steps didn't help you, then please read this helpful short tutorial:
tutorial


Treval



Discussion

No Comment Found