Hi I am new to linux and I'm trying to run java file. I am following this site:
http://www.source-code.biz/snippets/java/7.htm
in "installation instruction" when I reach to,
javac JavaDaemonTest.java
I found error command not found then I go to the place where I install jdk 1.6
usr/java/jdk1.6/bin here I found javac command and then I try to run
javac JavaDaemonTest.java
still I am getting 'command not found error'
my environment variable in bash profile is set that is,
PATH=$PATH:$HOME/bin
export JAVA_HOME=/usr/java/jdk1.6.0_29/
export CLASSPATH=/usr/local/apache-tomcat-5.5.34-src/servletapi/jsr152/examples/WEB-INF/lib/jstl.jar:/usr/local/apache-tomcat-5.5.34-src/servletapi/jsr152/examples/WEB-INF/lib/jstl.jar
export PATH
unset USERNAME
how to get out of it
Thanks in advance.
its nothing about Java here, its just your shell doesn't know where to search for javac
Add to the $PATH env. variable your $JAVA_HOME/bin and try again. It should work now
Related
I'm trying to get a working build system for Java on Sublime Text 3, but whenever I try to run anything, i just get bash: javac: command not found.
The strangest thing about this is that I can run the javac command from a terminal, as I have added the line
export JAVA_HOME=/usr/lib/jvm/java-14-openjdk && export PATH=$JAVA_HOME/bin:$PATH
to the .bashrc file in my home directory.
So I have no idea why I can run Java files using javac and java from the terminal, however Sublime Text cannot.
Here is what I have for my build system:
{
"shell_cmd": "javac \"$file_name\" && java \"$file_base_name\"",
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"selector": "source.java",
}
I am using Manjaro 20.
I see that you are using Manjaro, which is Arch derivative; instead of setting the JAVA_HOME variable, you should use archlinux-java to set the default JDK version.
archlinux-java is part of java-runtime-common package.
When something is wrong, Sublime will print your current path variable (example). Make sure the paths are set correctly.
I tried your build system on my Arch machine, and it is working correctly, I also tried setting the JAVA_HOME variable, and it is still working.
Using Sublime Text 3 Build 3211
For future users with the same issue, I solved it by specifying the path variable in my build system by adding:
"path":"your/directory/here"
The whole thing where I added the line to .bashrc turned out to be completely unnecessary, as this fixed it.
So, I am trying to run a program from jar files. It uses javaswing and has a gui.
The program runs fine in netbeans and in eclipse.
When I try to run it from the exported jar file it says this:
Unable To Install Java
There are errors in the following switches:
"C:\Users\CNC Department\Desktop\ValveConversion.jar";.
Check that the commands are valid and try again.[java installation not complete
Now, I also tried doing it from the command prompt. Here is what came up:
[cmd prompt attempt][1] [1]: https://i.stack.imgur.com/7reZ3.png
So, I reinstalled the java JDK, java SDK, netbeans and eclipse. The issue is still occurring in both command prompt and from running the jar file directly.
What am I doing incorrectly here? What do you recommend that I do to get this to run from a .jar file?
You need to set the java path
Open a cmd with elevated privileges and run this command to set the JAVA_HOME environment variable using setx command:
setx JAVA_HOME -m "C:\Program Files\Java\jdk-11.0.2"
Then restart the cmd and run java -version to check if it's all ok.
For reference setx command documentation
Or simply use the following snippet if you prefer to use java without setting the PATH variable:
"C:\Program Files\Java\jdk-11.0.2\bin\java" -jar "C:\Users\CNC Department\Desktop\ValveConversion.jar"
I am new to Java. I am using System.getenv("SPARK_HOME") to get the spark home path in given machine. When the Java application runs on ubuntu machine it gives null. The above property is set in bashrc (did source .bashrc). Tested through echo $SPARK_HOME which prints the value and also with printenv |grep SPARK_HOME.
I referred this answer, but it dint help to solve my problem.
Before running the jar run the following command:
$ source ~/.bashrc
$ java -jar myJar.java
I'm trying to use Jmeter but am coming across an issue when I try and run it using the Jmeter.bat file.
It's spits out the following error:
'java -version 2>&1 | findstr /i "version"' is not recognized as an internal or external command, operable program or batch file.
Not able to find Java executable or version. Please check your Java installation.
errorlevel=2
Press any key to continue . . .
I've tried googling this and lots of posts mention that this error is usually down to the environment variables not being set correctly, but I'm fairly sure they are as if I type java or javac into the command prompt I get a response.
I've got them set as follows:
JAVA_HOME : C:\Program Files\Java\jdk1.8.0_25
JDK_HOME : %JAVA_HOME%
JRE_HOME : %JAVA_HOME%\jre
CLASSPATH : .;%JAVA_HOME%\lib;%JAVA_HOME%\jre\lib
PATH : your-unique-entries;%JAVA_HOME%\bin
I tried taking the string it's complaining about and pasted that into the command prompt by itself and it ran fine:
C:\Windows\System32>java -version 2>&1 | findstr /i "version"
java version "1.8.0_25"
So why is it throwing the error when running the batch file but not if I paste it in manually? The batch file is located in a folder in my C drive and I'm running by right clicking and selecting 'Run as Administrator'. If I just double click the .bat file I get the error:
Windows cannot find 'C:\apache-jmeter-2.13_src\bin\jmeter.bat'. Make sure you typed the name correctly, and then try again
Is the above error related or is that a separate permissions issue?
Thanks for any help
From command Prompt go to bin folder of apache jmeter and type following command:
C:\apache-jmeter-3.0\bin> java -jar ApacheJmeter.jar
I also faced similar problem when I extracted the JMeter in C. In my case, i don't have admin rights. I assume it is related to some permission issue. So better copy to D: and then check.
Copy C:\apache-jmeter-2.13_src folder to other drive (D:) or download JMeter and extract in D drive and run the batch file.
I am trying to compile and a sample Helloworld.java file.
I have my jdk installed in C:\Program Files\jdk1.7\bin.
And I have my Helloworld.java in C:\Helloworld.java
I am actually a novice in both powershell and java.
I got some examples from web regarding this but many of them advice to run it like this:
java.exe -classpath $Env:CLASSPATH C:\Helloworld.java
But when I give this in powershell I get an error called 'CLASSPATH' is not defined even after adding it in env variables.
And when I try to compile the code with the following syntax:
$javac C:\Helloworld.java I get an error "javac is not recognised as a token".
So, I am literally lost in this topic . Any step by step procedure to run java programs using powershell for dummies like me will be greatly appreciated.
Setup environment variables in your system.
set JAVA_HOME to C:\Program Files\jdk1.7
add to PATH variable the string %JAVA_HOME%\bin
open new cmd session.
navigate your java source folder.
use javac to compile your java files.
UPDATE:
also if you are experiencing difficulities upon launching an executable via PowerShell check this Microsoft TechNet article
The variables you speak of do not exist in PowerShell as you name them.
The correct variable names are
$Env:JAVA_HOME: C:\jdk1.6.0;
$Env:PATH: C:\jdk1.6.0\bin;.;
$Env:CLASSPATH: C:\jdk1.6.0\lib;.;
As they all must be defined in the ENV: PSDrive
To answer it in a much simpler way , its the path problem .
You probably not have set env variables that's it.
This is how you should set it:
JAVA_HOME: C:\jdk1.6.0;
PATH: C:\jdk1.6.0\bin;.;
CLASSPATH: C:\jdk1.6.0\lib;.;
And later if you open a cmd prompt and type java -version , if you are able to see the java installed version then you are good to go.