UBUNTU 13.04 GNOME_DESKTOP_SESSION_ID - java

A recent upgrade to SQL Developer 4.0 in Ubuntu 13.04 has generated an error.
gnome_desktop_session_id=this-is-deprecated
my current work around is to just run
$ unset gnome_desktop_session_id
After this I can run sql developer and everything works fine.
Any suggestions on how to fix this with out having to run the unset command every time?

I modified /opt/sqldeveloper/sqldeveloper.sh:
#!/bin/bash
unset GNOME_DESKTOP_SESSION_ID
cd "`dirname $0`"/sqldeveloper/bin && bash sqldeveloper $*

You can make your system set it for you by putting this unset command to /etc/profile or in a .sh shell script that you place in /etc/profile.d/
If you launch SQL developper from console, you can also put the command in .bashrc

Related

Java not running in crontab

java -jar /home/scripts/relay.jar is working fine when I launch from command line. The command produces a file: relay.txt
In crontab
/usr/bin/java -jar /home/oneprovider/relay.jar
is not producing anything. I first had it without /usr/bin/ but then did which java and added absolute path with no luck. The jar file was originally written for windows but it works in Linux fine when launched from command line
What am I missing?
Agreed that the working directory is likely the problem. Can you write a shell script that wraps the java invocation and sets the working directory? Something like:
#!/bin/sh -e
cd /home/oneprovider
/usr/bin/java -jar /home/oneprovider/relay.jar
Then change the cron job to run the script instead. Remember to chmod it and make sure that the cron user can write to the directory if it isn't your personal crontab.

Use Windows Batch File to start a Java program

I am not familiar with batch script, but I want to create a Windows Batch File to start a Java program. The problem is that it has to specific the path where JRE is installed. When you install both JRE7 and JRE8, the name of that JRE8 folder would call something like jre1.8.0_20 or jre1.8.0_40 with the version number in the back. When you have only JRE8 installed, the folder would call jre8. Is there an easier way to find where the most updated JRE installed and then execute it? Thanks.
start ..\..\Java\jre7\bin\javaw.exe -Xms512M -Xmx1024M -Djna.library.path=.\lib -cp example.jar; com.example.main
You should be able to get the location of javaw.exe by executing where java. This can be set as a variable inside a batch file like this:
# sets a variable called 'java' to the location of javaw.exe
for /f "delims=" %a in ('where javaw') do #set java=%a
# execute you jar file
%java% -jar <app.jar>
Noticed that the above only seems to work when running directly from the command line. Here is another example that should work in a batch file:
# run.bat
#echo off
setlocal enabledelayedexpansion
for /f %%a in ('where javaw') do (
set java=%%a
)
!java! -jar %1
The above batch file should be called with the name of the jar file:
run.bat app.jar
I think it's best to just user JAVA_HOME and/or JRE_HOME and let the user / sysadmin worry what's installed.

Maven not finding Java even though it is set

Beating my head on the wall with this. Using Mac 10.10 and my java -version works but mvn -version gives me
error: JAVA_HOME is not defined correctly. We cannot execute /Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home/bin/java
and that's not even my correct jdk. Here is what my bash_profile looks like:export
export JAVA_HOME=/Library/Java/JavaVirtualMachine/jdk1.8.0_25.jdk/Contents/Home
export M2_HOME=/usr/local/apache-maven/apache-maven-3.2.3
export M2=$M2_HOME/bin
export MAVEN_OPTS=-Xms256m-Xmx512m
export PATH=$M2:$PATH
When I ran into this. I needed to restart the Terminal app. For it to pick up the new bash_profile changes.
That is (maybe) because iOS has a default Java installed and you have another Java VM that you downloaded yourself.
Try this, instead of defining the java home, let the OS use the one installed. In your profile, or on a shell script do this
export JAVA_HOME=`/usr/libexec/java_home -v 1.7`
Or whatever version of java you are using. For example, if you have java 6 and 7 installed, then running
export JAVA_HOME=`/usr/libexec/java_home -v 1.7`
will select java 7, whereas
export JAVA_HOME=`/usr/libexec/java_home -v 1.6`
will let you use Java 6.
NOTE the back ticks.
Please check the mvn.sh script, make sure you have not set the JAVA_HOME in it. Or redownload a maven package and unpack.
And check /etc/launchd.conf, have you set a JAVA_HOME in it?
install maven in mac/linux (mac in your case), should following this http://maven.apache.org/download.cgi section:Unix-based Operating Systems (Linux, Solaris and Mac OS X)
if your default terminal is bash (echo $SHELL will output something like: /bin/bash)
run echo $JAVA_HOME first before run mvn.
isaacdong-imac:~ isaac$ echo $SHELL /bin/bash
isaacdong-imac:~ isaac$
echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home
isaacdong-imac:~ isaac$
if your JAVA_HOME is empty, please note this:
export command ONLY current env of shell process. when you open a new shell or restart mac. export effect is gone.
see this: Set environment variables on Mac OS X Lion

tomcat7 wont run on startup

Tried everything but it just wont work, im running tomcat7 on an EC2 instance (amazon AWS). I can start up tomcat7 manually by starting startup.sh, but not automatically on startup. The error message I get in logs/catalina.out is the following:
/etc/apache-tomcat-7.0.32/bin/catalina.sh: 1: eval: /etc/jdk1.7.0_07/bin/java: not found
My enviroment variables are also setup properly:
echo $JAVA_HOME -> /etc/jdk1.7.0_07/bin/java
echo $PATH -> /usr/local/sbin:/usr/local/bin:/usr/sbin/:/usr/bin:/sbin:/bin:/usr/games:/etc/jdk1.7.0_07/bin
I can also type "java -version" in shell getting proper output, however "/etc/jdk1.7.0_07/bin/java -version" does not work and only returns "No such file or directory".
Im really not sure what to do now, feels like i tried everything, hope someone can help me!
Also the instance is running Ubuntu server 12.04.
Do sudo su vi /etc/bash.bashrc and copy following
JAVA_HOME=/etc/jdk1.7.0_07 //you have to only specify path until java dir not bin
export JAVA_HOME
PATH=$PATH:$JAVA_HOME/bin
export PATH
I do not particularly known about specifics of ubuntu+tomcat7 on EC2. So my answer could be missing a point a bit. It is given from generic ubuntu point of view.
Possibly things will be a bit easier to manage if you use apt-get to manage tomcat and java on ubuntu. In that case the tomcat will automatically started on start up. The commands below are tested on ubuntu 12.10, but also worked on some earlier version.
To install Java you need the following:
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer
If the first command fails, use the following:
sudo apt-get install software-properties-common
Then install tomcat7 using:
sudo apt-get install tomcat7
After that you need to tell tomcat to use installed java 7. For that purpose modify /etc/default/tomcat7 file either manually or using command like the following:
cat /etc/default/tomcat7 | sed 's/#JAVA_HOME=\/usr\/lib\/jvm\/openjdk-6-jdk/JAVA_HOME=\/usr\/lib\/jvm\/java-7-oracle/' >/tmp/tomcat7-updated
sudo cp /tmp/tomcat7-updated /etc/default/tomcat7
After that tomcat should load on start up. You just need to tune up ports and other configuration information. Note that this tomcat uses /var/lib/tomcat7/webapps/ to store web applications. You could also start or stop tomcat manually using the commands like the following:
sudo /etc/init.d/tomcat7 start
For automatic startup of tomcat, it should be started during booting time only.
For that you need to write a script which starts the tomcat and put this file in the etc/init.d or you can put it for different runlevels.
The hint for me was modifying the shell script file (set JAVA_HOME variable) and this resolved the issue.
The tomcat script file is generally under /etc/init.d/ directory

JAVA_HOME not found as Sudo

I have a bash script on a Linux box that runs a Jar file. When logged in as a regular user I don't have permission to run the script, but it prints the following log:
*INFO * Using JVM found at /opt/jdk6/bin/java
When I try to use the script with Sudo though, it gives:
*ERROR* Unable to locate java, please make sure java is installed and JAVA_HOME set
I've set JAVA_HOME to the same path above — can see it with echo $JAVA_HOME & it's also set as an option within the script. I'm happy that the script isn't the issue — it's a default CQ5 control script & I'm using it on dozens of other boxes without issue. Just unsure what I'm doing wrong above & presume it's something I'm missing re Linux set-up?
When I run the sudo command, does it have access to the JAVA_HOME that I set up as myself?
By default, sudo will cleanup the environment of the spawned commands. Pass -E to keep it:
sudo -E env
Compare to:
sudo env
"sudo -E " didn't solve the problem when JAVA_HOME was not exported. And when it was exported, "sudo " without -E works the same.
So you can add export JAVA_HOME=.../jdk<version> in your .bash_profile and .bashrc file.
In case you wondered what's the difference of .bash_profile and .bashrc, .bash_profile is executed upon login (e.g., show some diagnostic/welcome information). .bash_rc is executed when you open a new terminal (e.g., shift-ctrl-T).
In order to run some commands for both cases, you can put it in .bashrc file, and let .bash_profile source .bashrc:
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
You could always just pass it to java explicitly like this:
sudo java -Djava.home=$JAVA_HOME Test

Categories