I'm using jibx to convert a xml to JAVA and vice versa. Here, in an Ant script, I'm using the following code to load the JIBX_HOME path from the environment variable:
<property environment="env"/>
<property name="jibx-home" value="${env.JIBX_HOME}"/>
I have set the JIBX_HOME environment variable to .bashrc as follows:
export JIBX_HOME=/rezsystem/jibx_1_2_2/jibx
But this path is not loaded to the jibx-home property.
When I simply type $ set command in the terminal it prints. JIBX_HOME=/rezsystem/jibx_1_2_2/jibx successfully. What have I missed here? My OS is Ubuntu 12.10 and my IDE is Eclipse kepler.
I think you also have to add your environment variable with PATH also
like:
export JIBX_HOME=/rezsystem/jibx_1_2_2/jibx
export PATH=$PATH:$JIBX_HOME
Make sure you add the line to the current bashrc
like, key in on a shell,
vi ~/.bashrc
or
gedit ~/.bashrc
then enter the line at the end,
export JIBX_HOME=/rezsystem/jibx_1_2_2/jibx
don't use sudo command, save the file and restart the system.
If you print out the environment property using echo then is it set properly?
Ant properties are immutable anyway so you can just remove the entire not condition as you can't override the jibx-home property using your condition.
Try running eclipse with:
bash -ic "path to eclipse"
Do this after exporting JIBX_HOME variable.
I had to change my link to eclipse to this because it was not loading all env variables.
Try setting these environment variables in your .bash_profile instead.
Related
JAVA_HOME is not set currently. Please set JAVA_HOME. I want to run appium programs but its throwing this weird error
Even java_home path not displaying in terminal. Currently displaying blank
My bash profile
JAVA VERSION Is also getting displayed
try the following command:
vim .bash_profile (do you see export JAVA_HOME=$(/usr/libexec/java_home) under the file) ?
If not then you need to add it there.
If already added then run source .bash_profile, it reloads the file. And the path is set.
The first bash line is incorrect.
export JAVA_HOME=$(/usr/libexec/java_home)
Should be:
export JAVA_HOME=/usr/libexec/java_home
I am working on a ubuntu 14.0.4 machine.
I exported a variable TEST_HOME in my .bashrc file using
export TEST_HOME=/home/dev/code/test
When I tried echo $TEST_HOME from terminal, it returned /home/dev/code/test
So far, so good.
When I try from Java code :
String value = System.getenv("TEST_HOME");
value is null.
Am I missing something here?
Mentioning the variable in .bashrc will work only for programs started from shell. For system wide environment variables mention it in /etc/environment.
Refer Ubuntu Environment variables
.bashrc would set environment variable only for bash shell. To set it system wide set it in /etc/environment file.
Since you are using eclipse, and it does not run within bash shell, it is not getting the variable you are setting. If you run your programme using java command line in your terminal then it should get it.
Setting variable in /etc/environment would make it available to eclipse. You will need to restart your machine once you update /etc/environment.
I followed all the steps on pig.apache.org ,but not able to remove this error by setting java variable. I set the variable earlier while installing java jdk but its asking again for the variable.
You need to understand how environment variables work in Linux (or Windows).
The chances are that you only set JAVA_HOME temporarily in the shell that you used to do the installation. To set JAVA_HOME permanently (on Linux / UNIX) you need to set it in a shell "rc" file that gets run each time a new shell is created. (It depends on which shell you are using, but man can tell you about that ...)
if you are installing PIG on ubuntu do this
open bashrc file using below command and and lines to the end of the file
vi ~/.bashrc
export JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk-i386
then log out or Restart your system and try again.
For CentOS
Create a new file called java.sh
vim /etc/profile.d/java.sh
Within this file, initialize the necessary environment variables
export JRE_HOME=/usr/java/jdk1.5.0_12/jre
export PATH=$PATH:$JRE_HOME/bin
export JAVA_HOME=/usr/java/jdk1.5.0_12
export JAVA_PATH=$JAVA_HOME
export PATH=$PATH:$JAVA_HOME/bin
Replace java path with your java installation.
Source
To set your JAVA_HOME variable for your current shell, use the export command. This will immediately create an environment variable for JAVA_HOME, but the variable is lost when your shell is closed.
export JAVA_HOME=<path_to_java_sdk>
The best way to set the JAVA_HOME environment variable for Pig and Hadoop use is by adding it to your local rc file. The reason for this is that some distributions of Hadoop (Cloudera, Hortonworks, MapR) may include their own Java installation for the Hadoop application itself. You may not want to create a global environment variable, since it may interfere with Hadoop/Hive/etc.
To have the variable set for individual Hadoop/Pig users on the server, they need to run the following command:
echo "export JAVA_HOME=<path_to_java_sdk>" >> ~/.bashrc
Afterward executing the command, they can source ~/.bashrc to instantiate the environment variable.
I am new at web-services. I am trying to generate the stubs using this command:
wsimport -d ./build -s ./src -p com.ECS.client.jax http://webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl -b jaxws-custom.xml
I am getting this error in the cmd:
wsimport is not recognized
My Java environment variable system path is C:\Program Files (x86)\Java\jdk1.7.0. What am I doing wrong?
I resolved this issue by using wsimport from netbeans not from cmd...but I still don't know why I couldn't use it from cmd.
C:\Program Files\Java\jdk1.7.0_60\bin
This is where my jdk is, works for my system:
Go to My computer >> right click and select properties.
On the properties tab select Advanced system settings (Windows 7)
Click enviroment variables
select path and click edit option
add
";C:\Program Files\Java\jdk1.7.0_60\bin"
at the end.
Done.
wsimport and all other java commands are present in jdk bin directory and hence you need to update your PATH variable to include:
"C:\Program Files (x86)\Java\jdk1.7.0\bin"
instead of
"C:\Program Files (x86)\Java\jdk1.7.0"
I offer to create JAVA_HOME path. For example my JAVA_HOME:
JAVA_HOME c:\Java\jdk1.6.0_26\
My java path not include any special character and spacing between characters. Windows Path included this:
%JAVA_HOME%\bin;
or:
c:\Java\jdk1.6.0_26\bin;
Please check your Path. May be included wrong character, another slash, second java path or not included semicolon.
your java path is not set properly. what you can do is.
go to your java bin folder in your cmd prompt like c:\java\jdk.1.7.0\bin and enter your command like wsimport or wsimport -keep -s blahblahblah.
This will work!!!
You can also do this instead of changing the enviroment path variables
'C:\Program Files\Java\jdk1.8.0_60\bin\wsimport.exe'
And simply execute your code like:
'C:\Program Files\Java\jdk1.8.0_60\bin\wsimport.exe' -d ./build -s ./src -p com.ECS.client.jax http://webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl -b jaxws-custom.xml
I know this is an old post but I found this solution today and this was the way I solved!
Go to the environment variable. Under system variable choose "PATH" and edit it. In the new dialog box append path till bin folder of jdk. It MUST work.
If you're on linux and can't find wsimport as a default shell command, you might want to install openjdk-devel.
Actually the problem for this issue is system is not finding the java on the path variable. Eventually the command will work after adding the java on your system path variable..
This is the best solution for this problem:
run on your cmd this line:
c:>set path=%path%;C:\Program Files\Java\jdk1.8.0_51\bin
It should work.
I found it on
http://www.skylit.com/javamethods/faqs/javaindos.html
I just delete the entry in path as %JAVA_HOME%\bin and provide the direct path as C:\Program Files\Java\jdk1.8.0_101\bin . I don't know why because previously also it was pointing to same directory only.
What I'm trying to do is running a .java source by compiling and running it from command prompt (not using any IDE) using commands javac and java and the program connects with MySQL, so everytime I run the program from cmd, I need to specify path of the MySQL connector using -classpath switch of java. And entire command to run the program gets something like below:
java -class .;path/to/connector/mysql-connector.jar MySQLConnect
where I want it to be as simple as for other programs like java MySQLConnect
and it should run the program.
Is there any way I can add the connector's path to environment variables of Windows that java make use of it. I already tried by creating a new CLASSPATH variable in Windows environment variables and added absolute path of the connector with file name along, but that didn't worked.
Please provide me the workaround of this Windows and Ubuntu as well.
Thanks.
WIndows : Copy mysql-connector.jar to C:\Program Files\Java\jdk1.6.0\jre\lib\ext
and copy the same file to C:\Program Files\Java\jre1.6.0\lib\ext
go to My Computer -> Properties -> Advanced -> Environment Variables
Set these paths
JAVA_HOME
C:\Program Files\Java\jdk1.6.0
PATH
C:\Program Files\Java\jdk1.6.0\bin;
CLASSPATH
.;C:\Program Files\Java\jre1.6.0\lib\ext\mysql-connector.jar;.;
open a fresh command propmpt
type
java -version press Enter
WINDOWS
Go to My Computer -> Properties -> Advanced -> Environment Variables
then find CLASSPATH variable in System variables and click on edit to add your jar file there.
LINUX or MAC
In your shell use a variable CLASSPATH in your .bashrc or .profile to set a default class path.
Set classpath=%classpath%;location of mysql-connector with connector file name.jar. For example:
set classpath=%classpath%;D:\TECHNICAL\JAVA WORLD\JDBC\mysql-connector-java-5.1.18-bin.jar;
D:\TECHNICAL\JAVA WORLD\JDBC\ is the location of mysql-connector.
To set this path go to Advanced System Settings->Environment variables->User variables->CLASSPATH->Edit, then type set classpath=%classpath%;D:\TECHNICAL\JAVA WORLD\JDBC\mysql-connector-java-5.1.18-bin.jar; and finally press OK.
I have done in this style. After that, I got result of programs correctly. Then there is noCLassNotFoundException.