I'm trying to install the MS SQL JDBC driver on ubuntu to be used with sqoop for Hadoop. I'm totally new to java and linux, so I'm not sure where to extract everything to.
Just put it in the runtime classpath or add its path to the runtime classpath.
How to do it depends on how you're executing the program. If you're using java command in command console to execute a .class file, then use the -cp argument to specify the paths to classes and/or JAR files which are to be taken in the classpath. The classpath is basically a collection of absolute/relative disk file system paths where Java has to look for JAR files and classes.
Assuming that you've downloaded a .zip, you need to extract it and then look for a .jar file (usually in a /lib folder). For starters, it's the easiest to put the .jar in the current working directory and then execute your program (with the Class.forName("com.mysql.jdbc.Driver"); line) as follows:
java -cp .:mysql.jar com.example.YourClass
The . signifies the current path and the : is the separator (which I believe is correct for Ubuntu, on Windows it's ;).
To install the driver, you can:
Download the driver from Microsoft: https://www.microsoft.com/en-us/download/details.aspx?id=11774
Unzip and untar it (gzip -d sqljdbc_6.0.7507.100_enu.tar.gz and
tar -xf sqljdbc_6.0.7507.100_enu.tar)
Install it by copying the correct version into /usr/share/java (It will need to be world readable.) (sudo cp sqljdbc42.jar /usr/share/java/)
In the tomcat directory (/usr/share/tomcat8/lib but it could be tomcat7 if you are running a different version.) run sudo ln -s ../../java/sqljdbc42.jar sqljdbc42.jar (with the correct version names from below).
If you are using Maven, see Setting up maven dependency for SQL Server
The correct version is as follows: (Under System Requirements)
Sqljdbc.jar requires a JRE of 5 and supports the JDBC 3.0 API
Sqljdbc4.jar requires a JRE of 6 and supports the JDBC 4.0 API
Sqljdbc41.jar requires a JRE of 7 and supports the JDBC 4.1 API
Sqljdbc42.jar requires a JRE of 8 and supports the JDBC 4.2 API
Just put your jdbc jar file into /usr/lib/jvm/java-8-oracle/jre/lib/ext by using this command:
sudo cp ojdbc6.jar /usr/lib/jvm/java-8-oracle/jre/lib/ext
Related
I am trying to install Spring Boot CLI in Ubuntu. I am new to spring boot and was trying to learn it. I have already installed Gradle and groovy but did not find anything online to install Spring boot CLI.
please follow the code
sudo apt install unzip zip
curl -s https://get.sdkman.io | bash
source "/home/username/.sdkman/bin/sdkman-init.sh"=
sdk install springboot
spring version
The Spring boot CLI install guide link
Spring boot CLI
You can read the docs for installation steps:
Manual installation:
Download the Spring CLI distribution: you can find the latest version link here.
Extract the downloaded zip file to any path of your choice.
Prerequisite: Make sure you have Java JDK v1.8 or above (check INSTALL.txt file from extracted archive in Step-1). You can check your JDK version using command: java --version.
Add the spring CLI script's path to $PATH environment variable:
For example, you can add below lines to your .bashrc file in *nix systems:
export SPRING_HOME=/path/to/your/extracted-spring-cli/spring-2.4.0
export PATH=$SPRING_HOME/bin:$PATH
After saving the .bashrc file, run $ source .bashrc to reload the environment variables you just added.
(optional; and not for Windows user) Shell auto-completion scripts are provided for BASH and ZSH with the extracted archive in Step-1. Add symlinks to the appropriate
location for your environment. For example, something like:
ln -s /path/to/your/extracted-spring-cli/spring-2.4.0/shell-completion/bash/spring /etc/bash_completion.d/spring
ln -s /path/to/your/extracted-spring-cli/spring-2.4.0/shell-completion/zsh/_spring /usr/local/share/zsh/site-functions/_spring
To check if you are using BASH or ZSH, run the command: $ echo $SHELL.
DONE: To test if you have successfully installed the CLI you can run the following command: spring --version.
Here is detailed instruction on how to do it, much more useful than official one, at least for manual installation. One more thing - to make path change permanent you might need to logout - login, as "source /etc/profile" will be effective only for currently opened terminal.
Use this link to get a detailed instruction on how to download the Spring framework successfully, It really helped me a lot after long time of making research.
https://www.decodejava.com/download-and-install-spring-framework.htm
I have RHEL7.3 in which i have built tesseract and i am able to execute my jar . Now i have another system with same RHEL configuration and i want to execute the same jar But i don't want to build tesseract on this system so I pick /usr/lib64/libtesseract.so and /usr/lib64/liblept.so from previously builded tesseract system and put these so files in fresh RHEL7.3 system at /usr/lib64/
path and try to execute my jar but this time my jar did not execute succesfully .It ends with throwing 'java.lang.UnsatisfiedLinkError: Unable to load library 'tesseract': Native library (linux-x86-64/libtesseract.so) not found in resource path' .What did i miss(dependencies)
I have
- RHEL 7.3 (64 bit)
- JRE 1.8.0_51 (64 bit)
please try
yum install tesseract-ocr
I am trying to use Oracle SQL Developr.
When I try to open it, it asks for the jdk path. Whereas I have only a JRE installed.
I do not have admin privileges and I can not get it that.
I have tried modifying the sqldeveloper\bin\sqldeveloper.CONF file but it did not help.
Is there any alternative to do that.
I have searched for around 3 hours on Google. Nothing hits up straight.
And if you are planning to call it duplicate. I have gone through the similar questions but dint worked out. And installed as per the answer How to start Oracle SQL Developer 4 using 32 bit JDK on Win 64?. But there also ERROR pops up when I start.
I'm assuming you're using the SQL Developer that comes bundled with the Oracle database. IME, it's not worth struggling with that.
I'd recommend using the standalone version instead - it comes with its own JDK, all you need to do is unzip the archive.
UPDATE
Apparently, there's no standalone version of the current SQL Developer 4 for 32bit Windows. But you can use the 3.2.2 release instead.
Copied from this link just for getting it straight to the pointTRIED AND TESTED SOLUTION-With 100 upvotes
As I have tried it and it really works.Posting the solution here.
JDK is not available as a portable zip unfortunately.
However, you can:
Create working JDK directory (C:\JDK in this case)
Download latest version of JDK from oracle (for example jdk-7u7-windows-i586.exe)
Download and install 7-zip (or download 7-zip portable version if you are not administrator)
With 7-zip extract all the files from jdk-[6-7]u?-windows-i586.exe in directory C:\JDK
In command shell (cmd.exe) do the following:
--> change directory to directory C:\JDK\.rsrc\JAVA_CAB10
--> execute command: extrac32 111
Unpack C:\JDK\.rsrc\JAVA_CAB10\tools.zip with 7-zip
In command shell (cmd.exe) do the following:
--> change directory to C:\JDK\.rsrc\JAVA_CAB10\tools\
--> execute command:
for /r %x in (*.pack) do .\bin\unpack200 -r "%x" "%~dx%~px%~nx.jar"
(this will convert all pack files into jar)
Copy whole directory and all subdir of c:\JDK\.rsrc\JAVA_CAB10\tools where you want your JDK to be and setup manually JAVA_HOME and PATH to point to your JDK dir and its BIN subdir.
Thats all. After this you'll be able at least to use javac.exe
I have Mysql installed on my Linux box and wrote a sample program to access one of it's table.
I am using 'mysql-connector-java-5.1.10.jar'
The code is working fine if i put the jar in 'jre/lib/ext'. However, other ways of recognizing that jar are not working. I tried with setting $CLASSPATH and tried to use '.' current directory.
It's failing with the following error :
java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306
at java.sql.DriverManager.getConnection(DriverManager.java:602)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
I usually don't use the global $CLASSPATH variable, the easiest way to get it running is
java -cp .;/path/to/mysql-connector-java-5.1.10.jar[;<other libs>] pkg.name.MyApplication
Sidenote
If you have your application exportet to a jar with a Main-Class attribute ("executable jar") and start it with java -jar myjar.jar, then you have to add all required libraries to the jars manifest, $CLASSPATH and -cp are ignored in this case. And that's why I usually don't use the -jar option...
Edit
To answer your additional question: If the current directory was added to the classpath by default, then the location from where the application was started could influence the application itself.
Imagine an application inside a jar and a start command
java -cp application.jar com.example.Main
Now we have a defined environment: only the content of application.jar (and the jre classes) are on the classpath and part of the application. If the current directory was added to the classpath automatically then all files at the current location (and at locations of all subfolders) would be on the classpath too, intend or not. With a result, that the application might work if started from the users home directory but maybe not if started from the root directory (/).
I haven't done anything with Java in years, so I'm trying to get this done as simply as possible. I'm running Ubuntu 10.04. So far I've just done:
apt-get install solr-jetty libmysql-java
and set up all my config files to pull in documents from my MySQL database. Now, however, I'm getting this in the logs when I try to do a full import:
SEVERE: Full Import failed
org.apache.solr.handler.dataimport.DataImportHandlerException: Could not load driver: com.mysql.jdbc.Driver Processing Document # 1
Now I'm a bit stuck, because if apt installing libmysql-java didn't get me the JDBC driver, I have no idea what will.
These error means that your mysql dirver cannot be found on java classpath and you should just add it to it.
In case of Jetty you should put your database driver in $JETTY_HOME/lib/ext directory. Just put there symbolic link or copy jar file.
If you don't know where is MySql JDBC jar file you can check it using these command:
dpkg-query -L libmysql-java
Or you can just simply download these driver from MySql download page.
PS. I have never used Jetty and I found these information here: http://content.liferay.com/4.2/doc/installation/liferay_4_installation_guide/multipage/ch03.html#d0e893, point 9, Jetty 5.1 installation.
I ended up just symlinking to .jars from /usr/share/java; maybe there's a better way though.
ln -s /usr/share/java/mysql-connector-java.jar \
/usr/share/solr/WEB-INF/lib/mysql-connector-java.jar
sudo ln -s /usr/share/java/mysql.jar /usr/share/solr/WEB-INF/lib/mysql.jar
put the file mysql-connector-java-5.1.22-bin.jar (or its symbol link) to this directory:
/var/lib/tomcat6/webapps/solr/WEB-INF/lib/
I know this is for tomcat case but you can do the similar.