How to install j2sdk 1.4.2 on 64bit linux? - java

I have a problem with installation of java j2sdk 1.4.2 on 64bit linux (Ubuntu 10.04). Did anybody handle it?
uname -a
2.6.32-25-generic #44-Ubuntu SMP Fri Sep 17 20:05:27 UTC 2010 x86_64 GNU/Linux
I run a self-extracting file
sudo ./j2sdk-1_4_2_02-linux-i586.bin
but I get
tail: cannot open `+473' for reading:
No such file or directory
Oracle forum has no answer.

The problem is that the ubuntu tail command doesn't understand the 'tail +<>' syntax. You need to edit the file, being careful not to corrupt the content that is after the 473rd line, replacing the tail command with 'tail -n +473' instead. This should get you past this problem.

You should always prefer Ubuntu's package management system before trying to install software manually.
Is there a reason why you want to install the outdated Java version 1.4.2? It's better to install the latest Java version, which is version 6. Note that Sun Java 6 is backward compatible with 1.4.2; anything that runs on 1.4.2 will also run on Java 6.
Also note that you can use "javac -target 1.4" to ensure that the generated class files will be compatible with 1.4 JVM.
If you really have a special reason to install Sun Java 1.4.2: Ubuntu works with .deb (Debian) packages.

Try "chmod a+x ..."
is this package for 64 bit OS? how abt try to run it on a 32 bit OS?
When you run "sudo ./j2sdk-1_4_2_02-linux-i586.bin", are you really in the same path? how abt try to use absolute path.
obviously, #Jeroen Rosenberg's way is much better

you could have also temporarily replace tail command binary with a bash script, or alias or something, handling arguments the way you want :)

Related

Having trouble starting tomcat with a different JAVA_HOME

I want to start my tomcat with a different java version than the "standard one". On my server java 6 is installed (java -version returns: java version "1.6.0_34")
I also downloaded a java 7 jdk and put it to /opt/oracle/7/jdk1.7.0_55/ and wanted my tomcat to run with java 7. So I added export JAVA_HOME=/opt/oracle/7/jdk1.7.0_55 to my script /etc/init.d/tomcat7.
When I try to start my tomcat via sudo /etc/init.d/tomcat7 start I get /opt/tomcat7/bin/catalina.sh: 1: eval: /opt/oracle/7/jdk1.7.0_55/bin/java: not found
But when I type ll /opt/oracle/7/jdk1.7.0_55/bin I get -rwxr-xr-x 1 root root java* So the path should be correct!?
I can't figure out why it doesn't work. Any hints appreciated. :-)
EDIT:
I probably just downloaded the wrong jdk (32 bit instead of 64)
You probably downloaded the wrong JDK. From your comments, it seems to be a 32bit JDK. If you have a 64bit Linux, then you can't load the executables.
uname -m tells you the architecture of your system. It should be i686 or i586 but probably is x86_64.

How to silently install Java JDK into a specific directory on windows

On my development machine I always have to install Java 6 and Java 7 and I have to install each JDK in both, the 32 and 64 bit version, for testing purposes. Since the frequency of Java updates seems to be getting more and more ridiculous (twice per week by now?) each update requires me to un- and then re-install 4 JDKs. So this is getting really quite annoying and I would thus like to script this entire process.
My problem is, that by default each JDK versions installs into a directory-path that contains the update-number (default: "C:\Program Files\Java\jdk1.6.0_<update-nr>\"). To spare me from having to adapt tons of build-scripts I always manually strip the trailing "_<update-nr>" from the installation path and always install into the same "C:\Program Files\Java\jdk1.6.0" or "C:\Program Files\Java\jdk1.7.0", resp., for the 64-bit versions and into C:\Program Files (x86)\Java\jdk1.6.0" or "C:\Program Files (x86)\Java\jdk1.7.0", resp., for the 32-bit versions.
While I found out, how to specify the installation directory for a JRE installer (i.e. the Java runtime):
<jre-installfile>.exe [/s] [INSTALLDIR=<drive>:\<JRE_install_path>]
[STATIC=1] [WEB_JAVA=0/1] [WEB_JAVA_SECURITY_LEVEL=VH/H/M/L]
I did not yet find a similar description how to specify the installation directory for the JDK installer.
Does anyone know if and how one can specify the install path for the JDK installer, so that one can direct a silent JDK installation into a specific installation directory?
I could successfully install both x64 and x86 versions of JDK 8 update 60 including a public JRE with these commands:
Here JDK 1.8.60 (x86) with source code is going to C:\Java\x86\jdk1.8.0_60 and JRE to C:\Java\x86\jre1.8.0_60:
jdk-8u60-windows-i586.exe /s ADDLOCAL="ToolsFeature,SourceFeature,PublicjreFeature" INSTALLDIR=C:\Java\x86\jdk1.8.0_60 /INSTALLDIRPUBJRE=C:\Java\x86\jre1.8.0_60
In a similar way, JDK 1.8.60 (x64) with source code is going to C:\Java\x64\jdk1.8.0_60 and JRE to C:\Java\x64\jre1.8.0_60:
jdk-8u60-windows-x64.exe /s ADDLOCAL="ToolsFeature,SourceFeature,PublicjreFeature" INSTALLDIR=C:\Java\x64\jdk1.8.0_60 /INSTALLDIRPUBJRE=C:\Java\x64\jre1.8.0_60
See Oracle JRE installer options
I just found this article while searching... it specifies a parameter for INSTALLDIR.
http://makeitfaster.wordpress.com/2011/03/25/java-jdk-silent-install-on-windows/
jdk-7u2-windows-i586.exe /s ADDLOCAL="ToolsFeature,SourceFeature" INSTALLDIR="%CD%\jdk7u2"
I unfortunately had already installed on my dev machine, so i couldn't test...
One approach to avoid rewriting directories in scripts is to use symlinks (junctions on NTFS).
First, download the junction utility from SysInternals here:
http://technet.microsoft.com/en-us/sysinternals/bb896768.aspx
then unzip, copy to some directory on the PATH, and run once to accept the licence.
Then you can create symlinks easily:
junction "C:\Program Files\Java\jdk1.6.0" "C:\Program Files\Java\jdk1.6.0_37"
junction "C:\Program Files (x86)\Java\jdk1.6.0" "C:\Program Files (x86)\Java\jdk1.6.0_37"
To delete some symlink:
junction -d "C:\Program Files\Java\jdk1.6.0"
You can also use mklink ( http://technet.microsoft.com/en-us/library/cc753194.aspx ) instead (and del for removal), but I prefer the simplicity and clarity of junction.
Try:
jdk-7u2-windows-i586.exe /s INSTALLDIR=\"C:\Program Files\JAVA\JDK\"
I just discovered a regression in the JDK7 installer that causes it to ignore INSTALLDIR. The last correct version is update 21.
I have filed a bug report and will let you know once Oracle replies.
UPDATE: It turns out that this was caused by an corrupt (incomplete) JDK installation. Once I uninstalled this version (Add/Remove Programs) the new installation ran just fine.
This is the way that works for me for JDK_7u55. I opted to have the JRE installed too:
PowerShell Commands
$strJavaInstallExe=<Your JDK executable>
$strJavaInstallDir=<The directory you want the JDK and JRE to install to>
$cmdInstallJava=$strJavaInstallExe+' /passive /log "'+$strJavaInstallDir+'\install.log" ADDLOCAL="ToolsFeature,SourceFeature,PublicjreFeature" INSTALLDIR="'+$strJavaInstallDir+'" INSTALLDIRPUBJRE="'+$strJavaInstallDir+'"'
Invoke-Expression $cmdInstallJava
Hope this helps!
EDIT - easier way
Execute jdk-7u60-windows-x64.exe /passive /log install.log INSTALLDIR:c:\pippo
Works with 7u45 and 7u60
OLD answer
The exe contains the msi installer. To extract is (for sure there are more elegant methods, but I know only this one)
Run the exe manually - you need to do it only the first time, to convert it to an msi
Grab the msi (and all other.cab file) from C:\Users\AppData\LocalLow\Sun\Java\jdx.x.y\jdk.x.y.z.msi
run msiexec /i jdkx.y.z.msi /passive INSTALLDIR:c:\pippo
file jreinstall.bat (example: storage in desktop) (replace jre for jdk)
#echo off
start /w %UserProfile%\Desktop\jre-8u65-windows-x64.exe /s
setx JAVA_HOME "C:\Program Files\Java\jre1.8.0_65"
exit

unable to run sqldeveloper on debian

I have installed jdk1.6.0_21 and sqldeveloper(using alien) on debian(lenny). Now when I run sqldeveloper it asks for J2SE installation path, after I type the jdk path it exits with the below error message.
Oracle SQL Developer
Copyright (c) 2008, Oracle. All rights reserved.
Type the full pathname of a J2SE installation (or Ctrl-C to quit), the path will be stored in ~/.sqldeveloper/jdk
/usr/java/jdk1.6.0_21
/opt/sqldeveloper/sqldeveloper/bin/../../ide/bin/launcher.sh: line 430: /root/.sqldeveloper/jdk: No such file or directory
Error occurred during initialization of VM
java/lang/NoClassDefFoundError: java/lang/Object
Error: SQL Developer can't recognize the JDK version
You might want to issue the following command:
echo '/usr/lib/jvm/java-6-sun' > ~/.sqldeveloper/jdk
also it can be
/usr/lib/jvm/java-6-openjdk
on the sqldeveloper home there is a file named sqldeveloper.sh (or datamodeler.sh) add the folowin line:
unset GNOME_DESKTOP_SESSION_ID
should be look like this:
#!/bin/bash
unset GNOME_DESKTOP_SESSION_ID
cd "`dirname $0`"/sqldeveloper/bin && bash sqldeveloper $*
That's all.
Adios
There are several possible causes for this error message:
The VM can't find the rt.jar file
The VM and the rt.jar file don't match (e.g. VM is version 1.6.x, rt.jar is version 1.4)
The JDK wasn't installed properly
What's the output of the following commands?
which java
java -version
/usr/java/jdk1.6.0_21/bin/java -version
Finally I found the problem, JDK was not installed properly. I installed a fresh copy of OpenJDK after that it is working fine.
I've got the same when i will install my SQL Developer as root, but use it as other user.. In my case looks like the Sql developer was makes file ~/.sqldeveloper/.... as root:root privilegies, but in home dir with sudo user.. It's strange but easy to fix as
chown youruser:yourgroup -R ~/.sqldeveloper
When you get several error messages that don't seem to make any sense, start by looking at the first error. In this case, that would be:
/root/.sqldeveloper/jdk: No such file or directory
It looks like sqldeveloper is trying to write the file, and failing. Are you running this as root? If not, can you think of any reason why sqldeveloper would think that your home directory is /root/?
It looks as if the two java versions (OpenJDK accessible via /usr/bin/java and JDK 1.6.0_21 get mixed up). I can only guess how it can be solved:
run update-alternatives --set java /usr/java/jdk1.6.0_21/bin/java
try to uninstall OpenJDK
possibly, you need to do both
Only replace in /opt/sqldeveloper/sqldeveloper/bin/sqldeveloper.conf
from:
SetJavaHome ../../jdk
to:
SetJavaHome /usr/lib/jvm/java-7-openjdk-amd64

Exception in thread "main" java.lang.UnsatisfiedLinkError: Could not load SWT library

What is the reason for the following error I am having:
Exception in thread "main" java.lang.UnsatisfiedLinkError: Could not load SWT library.
I am using Eclipse 3.5 SE on Ubuntu 9.04 Jaunty.
How can I resolve this error?
I had same problem with Oracle Java 7 and Eclipse on 32-bit system.
libswt-gtk-3.6-java and libswt-gtk-3.6-jni were already installed. What helped:
cd ~/.swt/lib/linux/x86
ln -s /usr/lib/jni/* .
Maybe this can be done reconfiguring Java alternatives or what.
I believe Mikolaj Lechtanski's workaround is more elegant.
create or edit /etc/eclipse.ini
Paste inside:
-vmargs
-Djava.library.path=/usr/lib/jni
exit
make sure the file is readable:
sudo chmod 755 /etc/eclipse.ini
This means the native libraries could not be found.
Either you have 32-bit libraries and you are running on a 64-bit machine or vice-versa.
also make sure you have the -Djava.library.path= set properly
See this page on how to run outside of eclipse
What versions of Java and Eclipse are you using, and are they 32-bit or 64-bit, and how did you install them?
Eclipse uses its own GUI library called SWT (it doesn't use Java's AWT or Swing), and it needs some native (non-Java) libraries for this. If you have 32-bit Java installed, you need 32-bit Eclipse; if you have 64-bit Java installed, you need 64-bit Eclipse (note, the Eclipse downloads page has 32-bit and 64-bit versions for Linux).
(Note that it doesn't depend on whether your Linux OS is 32-bit or 64-bit, but on whether your Java is).
I had a similar issue when running Eclipse remotely on a server via a "ssh -X" tunnel. I resolved it using "sudo apt-get install libswt-gtk-3.6-java" on the server.
Happened to me when starting some GUI java application on a headless server using X11 forwarding while only having openjdk-7-jre-headless installed. Installing the full jre solved the problem:
apt-get install openjdk-7-jre
I ended up doing
cd ~/.swt/lib/macosx/x86_64
ln -s /usr/lib/java/* .
which fixed that problem.

How to install a specific JDK on Mac OS X?

I want to install a specific JDK (the latest for example). For this, I went to the JDK download homepage: http://java.sun.com/javase/downloads/index.jsp.
I looked for a Mac version, but I'm a bit surprised to only see downloadable versions for Linux, Windows and Solaris...
Here's the message for Mac:
"Apple Computer supplies their own version of Java. Use the Software
Update feature (available on the Apple menu) to check that you have
the most up-to-date version of Java for your Mac."
OK BUT... when I update Java with Mac I have a JRE and not a JDK...
I don't understand why a JDK version doesn't exist that is easily downloadable/installable (like a jar to unzip?) for Mac...
In a comment under #Thilo's answer, #mobibob asked how to set JAVA_HOME in your .bash_profile on a Mac. Answer:
export JAVA_HOME=`/usr/libexec/java_home`
This will dynamically assign to JAVA_HOME the location of the first JDK listed in the "General" tab of "Java Preferences" utility.
See Apple Technical Q&A 1170: https://developer.apple.com/library/content/qa/qa1170/_index.html
EDIT:
If you prefer parentheses to backticks for command substitution, this also works:
export JAVA_HOME=$(/usr/libexec/java_home)
As the message says, you have to go to Apple, not Sun, for Java on the Mac. As far as I know, Apple JDK 6 is installed by default on Mac OS X 10.6 (Snow Leopard). Maybe you need to install the developer tools from your Mac OS X installation DVD (the dev tools are an optional install from the OS DVD).
See: http://developer.apple.com/java/
NOTE This answer from 16 Oct 2009 is now outdated; you can get the JDK for Mac OS X from the regular JDK download page on Oracle's website now.
For people using any LION OS X 10.7.X
They uploaded Java SE 6 version 1.6.0_26 available here
http://support.apple.com/kb/dl1421
I bought a MacBook Pro yesterday (Mac OS X v10.8 (Mountain Lion)) and there is no JDK installed by default...
As well as javac, I also found it didn't have packages such as SVN installed. It turns out you can get everything from the Apple developer page (you will need to register with your AppleID). SVN is part of the "Command Line Tools" package.
This is what happens on a fresh MacBook:
Hopefully this will help out other newbies like me ;)
The explanation is that JDK is a bit specific and does not contain the library tools.jar. For my development, I need this library and Mac's JDK doesn't provide it:
(Cf. http://developer.apple.com/mac/library/documentation/Java/Conceptual/Java14Development/02-JavaDevTools/JavaDevTools.html)
tools.jar does not exist. Classes usually located here are instead included in classes.jar. Scripts that rely on the existence of tools.jar need to be rewritten accordingly.
It sucks!
The easiest way is to use Homebrew.
Install Homebrew and then:
brew tap caskroom/versions
brew cask install java7
You can list all available versions using the following command:
brew cask search java
Mac comes with the JDK, for more information check:
http://developer.apple.com/mac/library/documentation/Java/Conceptual/Java14Development/02-JavaDevTools/JavaDevTools.html
Compiling with -source 1.5 -target 1.5 (in a JDK 6 environment) will honor only language elements that were in 1.5 and prior. Great. But there were no language changes in 6 anyway. Problem with this approach (on Mac with 1.6) is that using classes that came AFTER 1.5 will still compile because they exist in the rt.jar. So one could run in a 1.5 env and get a class not found exception with no prior warning when compiling. I found this out the hard way with javax.swing.event.RowSorterEvent/Listener. Both entered "Since 1.6" but are not caught with -source 1.5
If you installed brew, cmd below will be helpful:
brew cask install java
As of Mac OS X v10.6 (Snow Leopard), you can run Java 6 in 32-bit mode on either 32-bit or 64-bit Intel processor equipped Macs.
If you cannot upgrade to Snow Leopard, Soy Latte is a pre-compiled version of Java 6 for Intel 32-bit.
There are various tricky issues with having multiple versions of Java (Apple's own Java 6 and Oracle JDK 7 or even 8) on one's Mac OS X system, and using different versions for different applications. I spent some time writing up my experience of my experience of installing and configuring various versions of JDK on Mac OS X 10.9.2.
In 2022, give a try to sdkman, is better than brew
curl -s "https://get.sdkman.io" | bash
then open a new shell and try list to see what you could install ;-)
sdk list java
At time of writing you could use:
sdk install java 17.0.1-tem
Check this awesome tool sdkman to manage your jdk and other jdk related tools with great ease!
e.g.
$sdk list java
$sdk install java <VERSION>
Since most answers are out of date, here's what works as of end of 2018 under the assumption that
You want to install the GPL version of OpenJDK.[0]
You do not want to install Homebrew
In that case, grab the desired version from one the many available, freely usable OpenJDK editions, e.g.:
AdoptOpenJDK
Amazon Corretto (Great for production, includes backports)
Oracle GPLv2 OpenJDK
Some of these include installers, but if not you can do the following. Assuming here version 11.0.1 for Mac. In your favorite shell, run:
tar -xzf openjdk-11.0.1_osx-x64_bin.tar.gz
sudo mv jdk-11.0.1.jdk /Library/Java/JavaVirtualMachines
# Fix owner and group
sudo chown -R root:wheel /Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk
# (Optional) Check if the new JDK can be found
/usr/libexec/java_home
=> /Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home
[0] Note that the Oracle branded JDK has significant licensing restrictions allowing you its use basically only for testing, i.e., not for production. If you do not have a support agreement with Oracle, then it seems risky to me to use their JDK, especially since the differences to OpenJDK are minimal.
Edit: added more choices
I think this other Stack Overflow question could help:
How to get JDK 1.5 on Mac OS X
It basically says that if you need to compile or execute a Java application with an older version of the JDK (for example 1.4 or 1.5), you can do it using the 1.6 because it is backwards compatible. To do it so you will need to add the parameter -source 1.5 and/or -target 1.5 in the javac options or in your IDE.
JDK is the Java Development Kit (used to develop Java software).
JRE is the Java Runtime Environment (used to run any .jar file 'Java software').
The JDK contains a JRE inside it.
On Windows when you update Java, it updates the JRE automatically.
On Mac you do not have a JRE separated you have it, but inside the JDK, so when you update Java it will update your JRE which is inside your JDK;
it doesn't install an JDK for you. You need to get it from somewhere else.
As a rule you cannot install other versions of Java on a Mac than those provided by Apple through Software Update. If you need Java 6 you must have a 64-bit Intel computer. You should always have Java 5 and 1.4 and perhaps 1.3 installed if you have at least OS X 10.4.
If you have VERY much elbow grease and is willing to work with beta software you can install the OpenJDK under OS X, but I don't think you want to go there.

Categories