-1

I started to learn Java and the first task was do write a 'Hello World' Code. Saved it in documents and had to open it in cmd. thats what i type in:

cd documents
javac HelloWorld.java

my problem: I always get the error: file not found: HelloWorld.java

the class is definitely HelloWorld and its saved to as HelloWorld.java

but when I open this document the path says:

C:\Users\myusername\OneDrive\Documents\HelloWorld.java

hope you can understand my problem, thx for answers

Erik
  • 3
  • 3
  • You are saving it to OneDrive. Are you cd'ing to that or the local documents folder? – 001 Jan 16 '19 at 18:39
  • yes i think so, but in the documents the type is aswell java-file – Erik Jan 16 '19 at 18:40
  • how can i change that it always save to onedrive and if i cd to onedrive i dont know how to access to the documents – Erik Jan 16 '19 at 18:46

2 Answers2

0

You can just use the change directory to your specific directory.

cd C:\Users\myusername\OneDrive\Documents\
javac HelloWorld.java
Bruno Caceiro
  • 7,035
  • 1
  • 26
  • 45
  • it haven´t worked in documents there always came an error with can´t find this path... i had to save it at the desktop now it works. – Erik Jan 16 '19 at 20:02
0

Check if the java file is in your Documents folder, by writing:

dir

or for macos:

ls

But since you said it is in your OneDrive then you should navigate there with the cd command. (Use TAB to fill out the folder names and/or filenames for you automatically. To check directory just write cd without anything behind it in windows, or pwd for macos. When you've checked that the Java file is in your current directory you can just compile it normally with javac.

Evandro Coan
  • 8,560
  • 11
  • 83
  • 144
Tolli
  • 16
  • 1
  • 1
    thank you for your help. the path was very hard to find because of the onedrive, do you know how to turn off OneDrive? I dont know why it always take the OneDrive path. – Erik Jan 16 '19 at 20:05
  • Hmm maybe your texteditor saves it automatically there? I don't really know why it would do that. But what I do before I start writing something is to create the file before writing, and not writing and then saving (hope you get what I mean). To do that in macos write "touch filename.java" and in Windows write "copy NUL filename.java". This works for every file type. – Tolli Jan 17 '19 at 20:32