-1

I am at step 6 in the process of installing JDK onto windows using instructions from this website .

When I attempt to “Set the Current Drive to the drive where you saved your source file Hello.java” by typing “c:”, nothing happens (the instructions indicate that something like C:\xxx> should appear).

I have saved the hello world file in the C: directory as indicated in the previous step (step 5).

I am trying to start learning Java and any help would be appreciated.

Mitchell
  • 1
  • 2
  • You seem to also have to learn about using the windows command line :) - While being able to compile a Java application from the command line is helpful - and necessary imo - you might be better off starting with an IDE that handles that stuff for you, e.g. Netbeans or Eclipse. – Thomas Mar 31 '17 at 10:40
  • Note that you'll probably start at `C:\Users\your_username` so just using the `c:` command won't change anything (the command tells Windows to switch to drive C, where you already are). – Thomas Mar 31 '17 at 10:43
  • Where do you exactly type c: ? – eldo Mar 31 '17 at 10:43
  • Type dir to list everything in current directory, cd.. to go one upper cd dirname to go in directory – eldo Mar 31 '17 at 10:45

5 Answers5

2

I would suggest you to go for an IDE like eclipse or Netbeans for learning Java as you are learning you should focus more on language basics than configuration try use Eclipse IDE its opensource and very good for Java development and my preference too .

http://www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/marsr

Try this link which makes Hello world easy

http://www.java-made-easy.com/java-hello-world.html

To write a "Hello World" program follow these steps:

Start Eclipse.
Create a new Java Project:
File->New->Project.
Select "Java" in the category list.
Select "Java Project" in the project list. Click "Next".
Enter a project name into the Project name field, for example, "Hello World Project".
Click "Finish"--It will ask you if you want the Java perspective to open. (You do.)
Create a new Java class:
Click the "Create a Java Class" button in the toolbar. (This is the icon below "Run" and "Window" with a tooltip that says "New Java Class.")
Enter "HelloWorld" into the Name field.
Click the checkbox indicating that you would like Eclipse to create a "public static void main(String[] args)" method.
Click "Finish".
A Java editor for HelloWorld.java will open. In the main method enter the following line.
     System.out.println("Hello World");
Save using ctrl-s. This automatically compiles HelloWorld.java.
Click the "Run" button in the toolbar (looks like a little man running).
You will be prompted to create a Launch configuration. Select "Java Application" and click "New".
Click "Run" to run the Hello World program. The console will open and display "Hello World".
Rahul Singh
  • 16,265
  • 5
  • 49
  • 74
  • Use of IDE will greatly help beginning in java. – Hemin Mar 31 '17 at 10:47
  • I disagree, using a simple editor will force beginners to memorize the Java syntax by heart and investigate their mistakes in the compiler. Furthermore there is no "configuration" other than installing a JDK and setting it to your path. Plus an IDE can be overwhelming in the beginning. – skubski Mar 31 '17 at 12:38
1

you need to enter this command to navigate to C:\ drive (I'm not sure if this is case sensitive or not, just to be safe maintain case sensitivity)

cd C:\

after that enter

dir

to confirm whether your file is there.

Then use javac to compile

Vardaan Sharma
  • 917
  • 8
  • 18
1

Make a directory (example C:\myjava) then save your Hello.java file inside the myjava folder. Open your command prompt and type cd c:\myjava. Then type javac Hello.java to compile your code.

Jeffrey Hitosis
  • 325
  • 3
  • 13
0

1)After Installing JDK, Make Sure Java_Home Path is set. Find it Here!

2)After that, Create a new file at Desktop and name it "MyFirstJavaProgram.java"

3) Right click and open newly created file in notepad. 4) Insert following code into it.

public class MyFirstJavaProgram {

   /* This is my first java program.
    * This will print 'Hello World' as the output
    */

   public static void main(String []args) {
      System.out.println("Hello World"); // prints Hello World
   }
}

5) To Compile that program, open command prompt and browse its current path to Desktop.

6) Write command "javac MyFirstJavaProgram.java"

7) to watch output of your program write command "java MyFirstJavaProgram" your output will be at console.

Community
  • 1
  • 1
Hemin
  • 655
  • 1
  • 15
  • 28
0

You need to enter the following command:

C:\Users>cd\

It will navigate you to the C: drive then apply the command to navigate to the folder where you saved your source file C:\xxx

C:\ >cd xxx

then you will get..

C:\xxx>  
kourouma_coder
  • 1,010
  • 2
  • 13
  • 21