Need help downloading JDK within Java - java

(BTW moderators, I HAVE checked other questions, and tried their methods which did NOT help in my situation. My primary account got banned from asking questions for 6 days which lead me to create this account.)
I need help downloading JDK in the java application.
When I try to run my program I am met with the error of "my JDK path was not set". I clicked the button that allowed me to set up a path for it, and I was met with a window with the download link to http://www.javasoft.com .
I go there I get redirected to this site: http://www.oracle.com/technetwork/java/javase/downloads/index.html
Upon redirection, I click the "DOWNLOAD" button under the text JDK.
After that I get sent to a webpage that had the JDK download links for each system. Naturally, I click the link for "Windows 64".
After opening the file I meet up with a window that should guide me through the installation. I clicked Next twice, and It downloaded. Then It allows me to put in the location of the Destination folder, the default destination was the exact same as what Jcreator told me to go to. So I proceeded, And it gave me the screen that said "nearly 3 billion devices run Java" and it completed the installation. I got a finish dialogue screen with the option that prompted me to download optional Jcreator programs, of which I declined and clicked "close".
I went to Jcreator again and I was met with the same message saying that my JDK path was not set up. I repeated this process 4-5 times.
And yes, moderators I HAVE checked other questions, and they all told me the same thing, however The askers of those questions found it solved. They each said to go to the download link and such. When I asked the question on my other account, (which got banned from asking questions for six days) I got either a useless answer(Which got upvoted for no reason) or I get redirected to another question after my question got removed(again, The question I got redirected to, did not solve my problem).

I don't think downloading the jdk is problem here, but problem is that JDK path is not set up. Set your JAVA_HOME and jdk bin path in PATH variable. That should help.
Let's say your downloaded jdk to "C:\Java\JDK1.8".
Create new environment variable JAVA_HOME = C:\Java\JDK1.8
Edit your environment variable PATH to have C:\Java\JDK1.8\bin
If you are using a command prompt to run the other program, which needs java, close and open a new command window for the new env vars to be of effect.
Here is how you set up these env variables:
Set the JAVA_HOME & PATH Variable
Once you have the JDK installation path:
Right-click the My Computer icon on your desktop and select Properties.
Click the Advanced tab. Click the Environment Variables button. Under System Variables, click New.
Enter the variable name as JAVA_HOME.
Enter the variable value as the installation path for the Java Development Kit, which is the jdk path (C:\Program Files (x86)\Java\jdk1.8.0_45) you pasted in comment.
Click OK.
Find existing PATH variable and edit its value by adding %JAVA_HOME%\bin to the end
Click Apply Changes.
You might need to restart windows.

Related

Java JDK installer won't run

I tried the other solutions but they didn't worked, so please don't just say "It's a duplicated so now you have to open this link." Because I tried them.
I have Windows 8.1 and I installed Java 8 JDK some days ago, now I unistalled it because I've had some problems with it (like the PATH for cmd was not set), and after unistalling it I tried to open the Java installer, after the UAC popup nothing happen. I tried opening the installer "sandboxed" with the program "Sandboxie", the Installer opened 2 services, after a few seconds another service opened and then every service closed.
I have no error, no logs, nothing.
P.S.
I tried downloading again the installer 3 times, nothing changed.
Edit:
JRE Installer doesn't start either.
Edit:
I'm actually in safe mode with internet connection and the installer still don't want to run... I don't know what to do now...
I tried with "sfc /scannow" and it said there was no problem, I tried "DISM.exe /Online /Cleanup-image /Restorehealth" too, no problem got reported.
Edit:
I tried running the installer with a Guest account, nothing changed. Anyway I found a solution.
I searched for everything that contains "Java" in C:\ and I found some value (that could have prevented Java Installer from running because it thought Java was already installed), I deleted them (carefully, don't just delete everything on your computer, that's not the way.)
Now I tried launching the installer and.. Here we go! Finally I can install it.
Thanks to anyone who tried to help me, I appreciate it.
In my case problem was in C:/Users folder. Initially my OS language was not English, after changing, it causes some errors. I couldn't install jdk, couldn't run some desktop tools. After looking for the solution, I could found it. My user name in Users folder had non English letters. So, I changed name of user and it solved my problem:
https://superuser.com/questions/890812/how-to-rename-the-user-folder-in-windows-10
You should add java in Path:
Open the System Properties.
Find the Advanced Tab in the Properties Window. Click Environmental Variables.
Scroll down in the System variables and find the PATH variable.
Select the PATH variable and click the Edit button.
Add the Java installation path to the PATH variable (dir_java/bin)
And also create system variable JAVA_HOME
What antivirus are you using?
If your av has some kind of process viewer that you can use to see when it starts and when it terminates and if it is marked a suspicious. Here is a screenshot from my av. I use comodo image here
If your av doesn't have this feature, try turning it off during the installation. Remember to turn it back on after you're done

How to Download Java and run a file on command line

I know this is SUPER basic. I am very new to all of this. I tried to download java and run a helloworld by following these instructions: https://docs.oracle.com/javase/tutorial/getStarted/cupojava/win32.html
I got an error when I tried to use the "javac" command to compile. This is what appears in the command prompt:
C:\Users\USer18\Desktop>javac HelloWorldApp.java
'javac' is not recognized as an internal or external command, operable program or batch file.
Does this mean I downloaded java incorrectly? When I downloaded it, there were 3 different things to choose from, but I could only choose one, so I chose the first one. I tried to download java again and select the second one, but it said it didn't work.
Thanks in advance for helping me!
From the tutorial you linked, it tells you to "consult the installation instructions" found here: https://docs.oracle.com/javase/8/docs/technotes/guides/install/install_overview.html
For Windows JDK, the instructions linked are here: https://docs.oracle.com/javase/8/docs/technotes/guides/install/windows_jdk_install.html#CHDEBCCJ
The part you need to look for is "Updating the PATH Environment Variable"
Updating the PATH Environment Variable
If you do not set the PATH variable, you need to specify the full path
to the executable file every time you run it, such as:
C:> "C:\Program Files\Java\jdk1.8.0\bin\javac" MyClass.java
It is useful to set the PATH variable permanently so it will persist
after rebooting.
To set the PATH variable permanently, add the full path of the
jdk1.8.0\bin directory to the PATH variable. Typically, this full path
looks something like C:\Program Files\Java\jdk1.8.0\bin. Set the PATH
variable as follows on Microsoft Windows:
Click Start, then Control Panel, then System.
Click Advanced, then Environment Variables.
Add the location of the bin folder of the JDK installation to the PATH variable in System Variables. The following is a typical value
for the PATH variable:
C:\WINDOWS\system32;C:\WINDOWS;C:\Program Files\Java\jdk1.8.0\bin
Note:
The PATH environment variable is a series of directories separated by semicolons (;) and is not case-sensitive. Microsoft Windows looks
for programs in the PATH directories in order, from left to right.
You should only have one bin directory for a JDK in the path at a time. Those following the first instance are ignored.
If you are not sure where to add the JDK path, append it.
The new path takes effect in each new command window you open after setting the PATH variable.
When ever we execute any command, it is searched in the directory where we are current in or mentioned in PATH environment variable. The oly thing which you need is just add <path of yourjdk>\bin to PATH
Windows 10 and Windows 8
In Search, search for and then select: System (Control Panel)
Click the Advanced system settings link.
Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH environment variable does not exist, click New.
In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. Click OK. Close all remaining windows by clicking OK.
In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. Click OK. Close all remaining windows by clicking OK.
Windows 7
From the desktop, right click the Computer icon.
Choose Properties from the context menu.
Click the Advanced system settings link.
Click the Advanced system settings link.
In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. Click OK. Close all remaining windows by clicking OK.
Reopen Command prompt window, and run your java code.

Ionic build failed; invalid %JAVA_HOME% (android)

I've searched around a bunch and could not find an answer that could help me.
I get this message when building my Ionic project for Android. I have verified, that both java -version and javac work in the folder, so both are accessible via the %path%.
What can I do to resolve this, and did I miss something?
I'm not familiar with Ionic but apparently it is not using %PATH% , it is using %JAVA_HOME%. You need to set it.
Determine the directory of a Java JDK (not JRE) in your system. It could be something like C:\Program Files\Java\jdk1.8.0_65. Since javac responds, you must have a JDK in the path somewhere. This directory will be the value for JAVA_HOME. (NOTE: This is not the same as the Java bin directory in the path! There should not be a bin on the end of the directory.)
Open the System page in your Control Panel.
You can do this in various ways:
Open an Explorer window, right-click on This PC and click on Properties in the menu.
Open Control Panel, click on System and Security, click on System.
Click on Advanced System Settings.
The System Properties window opens. Select the Advanced tab.
Click on the Environment Variables... button.
The Environment Variables window opens. Look at the bottom section labeled System Variables. You should see a variable named JAVA_HOME in the list. If you have this variable, double-check that the directory in the value exists and is a valid JDK directory.
If you don't see JAVA_HOME in the list, click the New... button. If JAVA_HOME is there but it's the wrong value, select JAVA_HOME in the list and click the Edit... button.
The New System Variable or Edit System Variable window will open (they look about the same.) Enter "JAVA_HOME" for variable name and the JDK directory for variable value. You can use the Browse Directory... button to make sure you have a valid directory for the value.
Click the Okay button on the New/Edit System Variable window, then the Environment Variables window, and then the System Properties window.
You will need to log out and log in again for the JAVA_HOME variable to take effect.

Javac isn't working in windows command prompt

javac not working in windows command prompt
^I tried the suggestions on this post, and it was SLIGHTLY helpful, but not completely.
I opened up my command prompt and I typed in "javac" after putting in the path in my Environment Variables and it didn't work, at which point I googled it and found that thread.
I knew that I had closed and re-opened my cmd already, and that didn't work, so I skipped that bit and I saw the part telling me to make sure that javac.exe exists, which I verified with the "dir" command in the cmd. Afterwords, while in the "C:\Program Files\Java\jdk1.7.0_25\bin" folder on the command prompt, I typed in the next bit of advice, which was
for %i in (javac.exe) do #echo %~$PATH:i
After entering this into my command prompt, I got the message "ECHO is on". Upon seeing this, I typed in "javac" again and this time, it worked. So I decided to test this out by backing out of the directory and going to a folder in which I had a .java file saved and running it, but it again told me that
'javac' is not recognized as an internal or external command, operable program or batch file.
This was disappointing. I think it'll only work if I'm INSIDE the bin file on the command prompt, which is annoying because I'm not an administrator on this computer and it will be annoying to always have to get admin permission (from my parents) to code. They will also never give me the password. Can anyone help me? Thanks in advance! And sorry for the huge wall of text...
EDIT: Someone has asked what would the output of "echo %path%" be. It is this:
C:\Windows\system32;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\
^Is it not supposed to say this?
EDIT 2: #brano88...I think I did? I right clicked computer, went to properties, went to advanced system settings, clicked Environment Variables and went to the top part and pressed "New..." There, I entered the Variable Name as Path and the Variable Value as the location of the bin folder. Is this incorrect? I followed a YouTube tutorial step by step while doing this.
This one: http://www.youtube.com/watch?v=Hl-zzrqQoSE
How to run .java files from CMD
go to your Computer -> C: -> Program Files -> Java -> jdk1.7.0_25-bin
copy the path (example: C:\Program Files (x86)\Java\jdk1.7.0_25\bin)
Go to Control Panel -> System and Security -> System-Advance System
Settings -> Advanced -> Environment Variables
open the Environment Variables screen and go to System Variables and look for "Path"
after finding the Path system variable, double click it or press edit button and in the Variable value you paste the path from java you just copied after the last values already existing there.
Note!
make sure you DO NOT enter any extra space in this field as it won't work;
make sure you have one semi-colon before pasting the path, example: Path :
...%ANT_HOME%\bin;C:\Program Files (x86)\Java\jdk1.7.0_25\bin
Note! If you previously tried to compile the .java file in a CMD, close that CMD
and open it again as the changes made will take effect only using a new instance of CMD
Go to the location of the file.java , example:E:\Projects , right-click by holding the Shift button pressed inside your folder and in the options from the window that just appeared select: Open command window here
Another solution is to normally open a CMD and change the directory using :
cd command until you reach your folder
After the CMD window opened, type: javac HelloWorld.java
Note! Make sure the class name written in your file.java is the same as the file name. Example your file name should be: HelloWorld.java and your class inside that file must also be:
class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World!"); // Display the string.
}
}
Otherwise, it will not compile!
It is successful if no error message is displayed, if the path of the folder appears again in CMD and of course if the HelloWorld.class file appears now in the directory. To check that type the command dir which will show what contains your currect directory.
To finally run the file type in the CMD: java HelloWorld
Observe that no extension is needed when running the file(the file you run already has the .class extension)
This is how it worked for me! If something is not right, please inform me! Thanks!
For a beginner programmer that doesn't have admin rights on his/her computer, I'd recommend the Eclipse IDE.
Since you already have the JDK the only installation step needed requires no admin rights. From here you must download the "Eclipse Standard" option, and you will get a very large zip archive. You can extract it onto the desktop or my documents. Windows comes with a utility to do this via drag-and-drop right from the explorer or your machine may have another program such as WinRAR installed to do this.
You can then run eclipse.exe from the place where you extracted it by browsing to, and double-clicking this file.
The IDE is very powerful and self-explanatory. You can create projects, run, and debug code, and it's nice for beginners. It's truly worth the long wait in downloading it.
First, yes you did add JDK to PATH. But you didn't do that correctly. You already have these variables added to PATH: C:\Windows\system32;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\
To add JDK put semicolon before you add it because you have multiple path's assigned to PATH variable. So it should be something like this:
C:\Windows\system32;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Java\jdk1.7.0_25\bin
in my case, javac was not working just because while specifying the path to javac in the path variable I gave space after putting semicolon to the end of the previous entry
To use javac from command prompt without typing the full location each time you will need to add it to the path.
I am unsure if you can change it without admin privileges, But on windows 7 with admin you can go to start -> Right click My Computer -> Properties -> Advanced system settings -> Advanced -> Enviromental Variables
You can then find the system variable path and append to the end of it, the location of javac.
The exact location of javac will vary depending on what version of the JDK you have installed, During installation you will have been given the option to choose where it was installed.
EDIT: Also make sure you haven't opened cmd as administrator. Or perform the steps in that video on the administrator account.
Adding variables to the top part of the environmental variables menu, mean they only affect the current user. You should be able to do these on normal account if you have someone type in the administrator password.

Viewing Java documentation with Eclipse on Mac OS X

I'm trying to accomplish a very basic task and somehow can't seem to find how... I would like to have my Eclipse environment set in a way that I can get help and documentation on any standard class/method in the JDK, like I used to do a few years ago with Eclipse on Windows, where having the cursor on a class name (e.g. PrintWriter), and clicking Ctrl+F2 would open up the Java documentation for the PrintWriter class.
Here's my environment:
Running OS X version 10.6.6.
Just downloaded and installed the Java Developer Package for Mac OS X 10.6 Update 4 from connect.apple.com
I have Eclipse Galileo installed.
Under /Library/Java/JavaVirtualMachines I have a file named 1.6.0_24-b07-334.jdk, which seems to be the new JDK I just installed. However, it's a single file, not expanded into directories and files. Right-clicking it and selecting "Show Package Content" shows me that deep inside it contains the files docs.jar and src.jar. However, not sure what I should be doing with the 1.6.0_24-b07-334.jdk file - should I leave it as is, or perhaps expand it to a full directory structure?
Under Eclipse Preferences, Java/Installed JREs I have JVM 1.6.0 (MacOS X Default) selected. However, the path points to /System/Library... and not to /Library...
Anyway, in Eclipse, putting the mouse over a class name, I get a brown dialog with a short explanation of the class. However, I don't know how to open up the full java documentation of the class. Also couldn't find anywhere in Eclipse a place to indicate where to take the java documentation from, nor which hotkey would bring the java documentation up.
I apologize for the many details, I'm just assuming they may be necessary to get a good answer.
Thanks!
/A
I've had the same problem — previously I had been able access Java documentation and source directly in Eclipse, but that disappeared after one of the Java updates from Apple last year.
My solution was to manually add the source and Javadoc to the JRE definition in Eclipse. Here's how:
Navigate to Preferences --> Java --> Installed JREs
Select your preferred JRE and click Edit...
Select the classes.jar library (should be the first one in the list) and click Javadoc Location...
Click Javadoc in archive
Set Archive path to /Library/Java/JavaVirtualMachines/1.6.0_24-b07-334.jdk/Contents/Home/docs.jar
Set Path within archive to docs/api
Click OK
now, optionally, you can set the source code too...
With classes.jar still selected, click Source Attachment...
Set Location path to /Library/Java/JavaVirtualMachines/1.6.0_24-b07-334.jdk/Contents/Home/src.jar
Click OK
In fact that 1.6.0_24-b07-334.jdk package is actually just a folder; it is treated as a single file by OS X but you can access its contents directly if you know the right path. What if you don't know what path the enter? You can browse the contents from Eclipse if you know this trick:
While attaching source code or Javadoc in Eclipse, click on the External File... or External Folder... button etc to bring up a Finder window
Navigate to your Java JDK folder (usually /Library/Java/JavaVirtualMachines)
You should see a list of your JDKs, for example 1.6.0_22-b04-307.jdk and 1.6.0_24-b07-334.jdk)
Press / on your keyboard to bring up the Go to the folder dialog box
Delete the / from the dialog box, and start typing the name of JDK you want to navigate. You can press Tab to autocomplete the name if you like.
Click Go
You are now browsing the contents of the JDK package; you can now click through to Contents/Home etc where you should see appledocs.jar, docs.jar, src.jar and other goodies.
For everyone finding this StackOverflow-Post and not finding the src.jar:
Apple removed it from the SDK and it's not supplied by default, however you can download it from Apple self at:
http://connect.apple.com/cgi-bin/WebObjects/MemberSite.woa/wo/5.1.17.2.1.3.3.1.0.1.1.0.3.9.3.3.1
http://danbim.blogspot.com/2011/01/java-for-mac-os-x-106-update-3-and.html
P.S. Apple account is required (free registration)
To bring up the Java documentation in Mac, move your mouse to the desired class, then click SHIFT+FN+F2.
By the way, you can find out the shortcut key from Preferences -> General -> Keys -> type "Open Attached Javadoc". Here's my screenshot:-
Under /Library/Java/JavaVirtualMachines I have a file named 1.6.0_24-b07-334.jdk, which seems to be the new JDK I just installed. However, it's a single file, not expanded into directories and files. Right-clicking it and selecting "Show Package Content" shows me that deep inside it contains the files docs.jar and src.jar. However, not sure what I should be doing with the 1.6.0_24-b07-334.jdk file - should I leave it as is, or perhaps expand it to a full directory structure?
From what I remember from Mac OS (I had to use one two years ago for some months) I think this is not really a "single file", it only looks so in the file manager application. Look if you can navigate inside it in the file-chooser dialog of eclipse where you can select the docs.jar for your documentation.
I was having a similar problem, and was having trouble accessing the Apple Developer page to download a local copy of the docs.jar. I went to Preferences > Java > Installed JREs > Edit, and then looked at the "Javadoc Location..." value for the jars. The Javadoc URI was still set to "http://java.sun.com/javase/6/docs/api/". When I changed it to "http://docs.oracle.com/javase/6/docs/api/" the tooltips started showing up again. Of course, this will only work when you are online.

Categories