Why does CMD not recognize the javadoc command? - java

I installed JDK on windows 10, 64bit, followed the documentation instructions.. CMD does not recognize javadoc command. What I tried:
-copied the path of the "bin" folder from Java and in cmd I wrote the command:
set path = "full_path_to_java_sdk_bin_folder"
I saw this on youtube and it worked for the guy, my cmd still did not recognize javadoc command -I set the PATH in system variables from control panel->system->advanced->environment variables and made sure that there are is no other bin folder...
Didn't find any other tips online...

The usual approach for Java development is to set a JAVA_HOME environment variable, and use that to update the PATH (for one thing, it makes it much easier to support multiple versions of Java). Also of note is that Windows puts the quotes oddly on the command line (oddly compared to every other platform that is) and if your path contains spaces you need to quote it correctly. Like,
set "JAVA_HOME=<full_path_to_jdk>"
set "PATH=%JAVA_HOME%\bin;%PATH%"

Related

Using Ctags with Gvim on Windows

I'm using gvim as my main 'IDE' on windows 7 and I would like to use ctags to navigate through the code. I've downloaded it and ran based on this tutorial: http://www.techrepublic.com/article/configure-vi-for-java-application-development/5054618
ctags -f ~/.tags -R ~/myprojects/src $JAVA_HOME/src
I've then setup my vimrc with...
set tags=~/.tags
However when I do Ctrl+] on a keyword, it says it can not find the file which the tag is defined in. Shows the correct path except it misses out c:\ from the start so vim can't load it.
How can get it to give me the correct path?
I'm using the latest version of gvim and ctags.
Thanks
FWITW, I'm not entirely sold on the concept of keeping my tags in one location.
This part of the command call:
-f ~/.tags
Nor would I hard path to my current project. This part:
-R ~/myprojects/src
BTW, Windows doesn't have ~ so I don't think either of those would work (not sure if Vim will find ~, i.e. "home").
If I were you, I would cut my teeth on the simplest method until you get more comfortable with the Vim methods and ideals.
Easiest method:
Always let Vim know the "Current Directory" (making the assumption that you are not launching Vim via the command prompt). When you open a file always set the current directory by issuing the following command from normal mode:
:cd %:p:h
Generate a tag file in the current directory with the following command (from normal mode).
:!ctags -R .
Happy jumping.

An easy question about java and environment variables in ubuntu

I have Ubuntu 10.10 with java already installed. I am able to execute java command from any folder. I supposed that could be because I had java Classpath setted. But neither JAVA_HOME nor CLASSPATH are setted.
If I look at /etc/environment content I can see that PATH is setted to /usr/bin/ (among others). As 'which java' returns /usr/bin/java, is that the reason why I can execute java from anywhere? If not, why is it?
You can execute java because the command is on your path.
echo $PATH
will show you which directories are searched, in which order to find a particular program. Since /usr/bin is on your path, when you type java it will eventually look at /usr/bin/java. Note that in many systems this is a symbolic link (a file that points to another file) so /usr/bin/java often points to /etc/alternatives/java (which is also a symbolic link that points to the real executable).
Where the environmental variable JAVA_HOME comes into play is in tools and programs that check for JAVA_HOME and act on it instead of relying on the path. In most modern Linux systems, the work done by the alternatives subsystem replaces the earlier (more problematic) JAVA_HOME technique. That said, you might want to set JAVA_HOME anyway, should you encounter a tool that demands it.
One reason why JAVA_HOME is not as popular as it could be is that to access JAVA_HOME you need to run a shell, and not everyone wants to wrap every single Java item in a shell command.
Yes, if java binary (or a link to it) is on a folder that is listed on the path then you can execute java without specifying the path to it (for example /usr/local/java/latest/bin/java -jar x.jar)
JAVA_HOME and CLASSPATH have nothing to do with system path.
JAVA_HOME allow other software (or scripts) to know where to look for java installation.
CLASSPATH tells java where to look for classes (.class files resulting of compiling .java files).

Mac User - How do I set CLASSPATHS in Mac (I'm working on a Lucene Demo)

I'm trying to get my Apache Lucene demo to work and I'm down to setting the classpath in this tutorial http://lucene.apache.org/java/2_3_2/demo.html
I've hunted the web and these wer the 2 solutions I found to set CLASSPATH:
CLASSPATH=${CLASSPATH}:/Users/philhunter/Desktop/COM562\ Project/lucene-3.0.3/lucene-core-3.0.3.jar
and
setenv CLASSPATH ${CLASSPATH}:/Users/philhunter/Desktop/COM562\ Project/lucene-3.0.3/lucene-core-3.0.3.jar
The second one brings up a error
-bash: setenv: command not found
The first one seemed to accept ok but wen i tried the next step in the tutorial i got an error. The next step was to run the following:
Phil-hunters-MacBook:webapps philhunter$ java org.apache.lucene.demo.IndexFiles /Users/philhunter/Desktop/COM562\ Project/lucene-3.0.3/src
which gave me the error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/lucene/demo/IndexFiles
This leads me to believe my CLASSPATHS didnt set correctly. Would I be right in assuming this? I have tried other tutorials and demos and see to get this same error quite a bit. Im new to Lucene and relatively new to mac and Unix shell scripting. Anyone know if I am setting the CLASSPATH correctly and if thats the cause of the errors?
in the terminal type
$ vim ~/.bash_profile
edit the file and add one line:
export CLASSPATH=${CLASSPATH}:/usr/local/lucene-3.6.2/lucene-core-3.6.2.jar:/usr/local/lucene-3.6.2/contrib/demo/lucene-demo-3.6.2.jar;
make sure to change the path of yours.
In your way you lose to add lucene-demo-3.0.3.jar in your classpath.
When you set an environment variable like CLASSPATH then by default it only applies to the current process (i.e. the shell process itself) - it isn't available to the java process you launch in the next line. In order to make it available to other processes you need to "export" the variable. In this case you can use something like:
export CLASSPATH=${CLASSPATH}:/Users/philhunter/Desktop/COM562\ Project/lucene-3.0.3/lucene-core-3.0.3.jar
This basically says "set the CLASSPATH variable to its current value plus the location of the lucene jar, and make the new variable available to any processes launched from this shell".
However, with java the usual way of setting the classpath is to do it as part of the java command itself, using the -classpath or -cp options. In your case it would look something like:
Phil-hunters-MacBook:webapps philhunter$ java -cp /Users/philhunter/Desktop/COM562\ Project/lucene-3.0.3/lucene-core-3.0.3.jar org.apache.lucene.demo.IndexFiles /Users/philhunter/Desktop/COM562\ Project/lucene-3.0.3/src
As an aside, the error you see when using the setenv line is because setenv is the command used in the C shell to set environment variables, but the default Mac shell (and the shell you're using) is bash which doesn't recognise setenv and lets you know it doesn't recognise it with the error message: -bash: setenv: command not found.
i create a .bash_profile file in my home directory and do things like
export GRAILS_HOME=/usr/share/grails
...
export PATH=${GRAILS_HOME}/bin:${GROOVY_HOME}/bin:/usr/local/mysql-5.1.45-osx10.6-x86_64/bin:${PATH}
you can work of that to set the classpath -- these examples show how to declare an environment variable and how to use the variable in other variables.

javac command prompt parameters

I installed java on my machine and I wanted to compile this group of source code. But when I opened up the command prompt and typed in javac, the command prompt said it was an unknown parameter. The same thing happened when I wanted to build something with ant (I had the build.xml if you are wondering) and the same thing happened. How can I set the javac and ant command to be used in any directory?
First of all you have to be sure you installed JDK and not only JRE
Secondly it depends on your operating system:
windows: you have to reach environment variables by using My Computer (manage->advanced->something here)
linux/osx: you have to export variables with export command or by using a .profile file in user directory
Then you need to set two things:
adding /jdk_1.6.../bin/ to your PATH variable
setting JAVA_HOME to your root of java installation ( /java_1.6..../ ) (maybe this is not required by java itself but many frameworks use it)
One note: on OSX, and maybe Linux too you have to split paths in PATH variable with double colon ':' instead that semicolon ';'
Add the directory the executable is in to the PATH environment variable.
Guessing that you are using Windows. Right click My Computer and click Manage. Then, in the Advanced tab, select Environment Variables. In the new window, under System variables, find Path and append the full path to the binaries (javac and ant) at the end, separated by semicolons.

How do I add `java` to the command path on Vista?

I have JDK installed in Vista. I want to run java from the command line. How do I configure the path variable?
If I'm not able to set the JAVA_HOME variable, what is an alternative?
Open My Conputer -> General Settings -> Environment variables and add as global
Key:JAVA_HOME
Value:C:\jsdk etc. etc.
And then modify the Path variable
Value ( type at the end )
....something;something;something;%JAVA_HOME%\bin
Reopen your command prompt and type
javac
And see if it works
EDIT
Moved my comment to the answer
The command prompt has some problems dealing with the empty space.
What I usually do is install the jdk directly on C: to get rid of space in "Program Files"
So installing it directly in C: will give you an "spaceless" path to the executable:
C:\jdk1.6.0_14\bin\javac
Instead of
C:\Program Files\Java\jdk1.6.0_14\bin\javac
Some times you'll get: C:\Program "executable not found" or something like that.
Installing directly on C: does the trick
I'd suggest looking at the java tutorial.
http://java.sun.com/docs/books/tutorial/essential/environment/paths.html
CLASSPATH manual
Running java from the command line
If the java program is available in your path then you should just be able to do;
c:> java -classpath somedir com.example.Main
if java isn't available to you then you can do
c:> SET JAVA_HOME=c:\path\to\java
c:> <same java stuff from above>
Use the -classpath option for the java command to specify where your classes are.
The value of the classpath option is a list of directories, JAR archives, and ZIP archives that contain classes, structured into directories that mirror the classes' package structure. The list uses the path delimiter, which is plaform specific: on Windows, it is ";", other platforms use ":".
Using the CLASSPATH environment variable is discouraged because changes for one program are likely to interfere with the operation of other programs.
There is some problem with Vista and the path variable containing %JAVA_PATH% if the JAVA_PATH value has spaces.
I fixed this manually by setting the %JAVA_PATH% to c:\program files\Java\<whatever> and then added to c:\program files\Java\<whatever>\bin to the Path variable in Vista.
If you deleted your My Computer icon, you can also go to Control Panel -> System -> Advanced system settings (which gives you System Properties dialog) -> Advanced tab -> Environment Variables. Path is listed in the second text window.

Categories

Resources