Link to home
Start Free TrialLog in
Avatar of sargent240
sargent240Flag for United States of America

asked on

Netbeans

I have some code I have written using Netbeans that will execute when I select Tools and Run Project but when I go to the Tools tab, select Clean and Build, and try to execute the program using:

java -jar diydj4

I get the following error is shown in the attached file.
javaError.png
Avatar of mccarl
mccarl
Flag of Australia image

The error is pretty self-explainatory. The version of Java that you are using to run the program on the command line is different (probably older) to the version used by Netbeans to compile the program. Check the following... run "java -version" on the command line to see which version you are trying to run it with. Also "which java" may be able to tell you the installation directory of this version of java. If you right click the project in Netbeans, and I think select "Properties" and then the "Libraries" tab, it should say what version of java it is compiled with (it has been a while since I have used Netbeans though so that might not be 100% accurate)
The code has been compiled to Java 1.7. Install the 1.7 runtime and your problems are over. Or compile using the -source and -target switches to get the version lower
Avatar of sargent240

ASKER

I did the installation process for java 1.7 with the following results;



Installing jre-7u9-linux-i586.rpm (installed size 91.33 MB)
Additional rpm output:
Unpacking JAR files...
      rt.jar...
Error: Could not open input file: /usr/java/jre1.7.0_09/lib/rt.pack
      jsse.jar...
Error: Could not open input file: /usr/java/jre1.7.0_09/lib/jsse.pack
      charsets.jar...
Error: Could not open input file: /usr/java/jre1.7.0_09/lib/charsets.pack
      localedata.jar...
Error: Could not open input file: /usr/java/jre1.7.0_09/lib/ext/localedata.pack
      plugin.jar...
Error: Could not open input file: /usr/java/jre1.7.0_09/lib/plugin.pack
      javaws.jar...
Error: Could not open input file: /usr/java/jre1.7.0_09/lib/javaws.pack
      deploy.jar...
Error: Could not open input file: /usr/java/jre1.7.0_09/lib/deploy.pack
HOW are you attempting to do the above install and on what system?
I went to the Java website and followed the instructions.  The instructions there say to download:

jre-7u9-linux-i586.rpm

Then they say, after removing the previously installed version, to:

rpm -Uvh jre-7u9-linux=i586.rpm

The the errors occur.
you did that as root i hope? And you didn't answer my question...
I don't see my last post I made on the 15th so I will do it again.  I did it as root and I guess I see one piece of info I failed to provide to you.  I am using the Suse 12.1 distribution of Linux.
If you can get it via Suse's package manager, that would be much better
Are you speaking of YAST?
I think it's Yast, yes. I stopped using rpm based distros a long time ago because of 'rpm hell'. I understand it's got a lot better since then. What should always be avoided (if possible) is to install software independently of the package manager.
When I bring up yast to do the install but it only has 1.6.0 available in the list.  My first attempt at the upgrade was with yast but there is no option for 1.7 just 1.6.0.
That will be (if you're sure you've updated the package db) because 1.7 is not yet stable on your system. Better to stick with 1.6 until it is
What would be the process to use 1.7 when Netbeans is using 1.7 and I have 1.6 on my computer.
Netbeans will use whatever Java it finds on the system. Just configure it for 1.6. Of course, you won't be able to use the few new 1.7 features
I guess I am not familiar with how to tell Netbeans to use 1.6.0.  I am wondering why Netbeans is using 1.7 if it is not on the computer.  If it is on the computer for Netbeans,  why would it not be available from the command line.
I guess I am not familiar with how to tell Netbeans to use 1.6.0.  
You'd configure it under Tools|Java Platforms

If it is on the computer for Netbeans,  why would it not be available from the command line.
Maybe because it's not on the PATH?
Would it be easier to put the 1.7 version in my path so it will be used when I try to execute the program from the command line.  I'm not sure how to add it to the command line path. Is it much of a task.  When I look in tools and JavaPlatforms I see all the 1.7 files.
Can you execute this command please and paste the content of /tmp/bash-stuff.txt?

ls -al ~/.bash* | tee /tmp/bash-stuff.txt

Open in new window

This is the result run as user:

al@linux-8agl:~> ls -al ~/.bash* | tee /tmp/bash-stuff.txt
-rw------- 1 al users 9919 Nov 17 19:59 /home/al/.bash_history
-rw-r--r-- 1 al users 1177 Jun  1 21:05 /home/al/.bashrc
al@linux-8agl:~>

This is the result run as root:

linux-8agl:/home/al # ls -al ~/.bash* | tee /tmp/bash-stuff.txt
-rw------- 1 root root 14043 Nov 17 20:30 /root/.bash_history
linux-8agl:/home/al #
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Been a long time since I have been able to look at this but I followed the above instructions placing:

/usr/java/

as the path in the first export command.  and placed the line:

export JAVA_HOME=/usr/java/jdk1.7.0_09

as the last line in the .bashrc file.  When I do the javac -version command it responds with

javac 1.6.0_24
Sorry, the path I used in the first export command was:

/usr/java/jdk1.7.0_09

the command actually read:

export JAVA_HOME=/usr/java/jdk1.7.0_09
Another observation, the directory I put in the export command has a jre directory and three html files in it.
You've confused me now ;) But my suspicion is that you didn't follow my instructions closely enough
Sorry 'bout that.  I had an error in my line that goes into the .bashrc file.  I corrected it and when I run java-version I get the following:

linux-8agl:/home/al # java -version
java version "1.6.0_24"
OpenJDK Runtime Environment (IcedTea6 1.11.5) (suse-16.1-i386)
OpenJDK Server VM (build 20.0-b12, mixed mode)
When I execute the:

env

command I do see:

JAVA_HOME=/usr/java/jdk1.7.0_09

line in the export list.  I wonder if I have the right directory?  In that directory there are three html files and a jre directory.  Is that what should be in the directory I should have in the export command and the line in the .bashrc file?
It might be less confusing if you could attach the .bashrc file to this question
.bashrc attached

# Sample .bashrc for SuSE Linux
# Copyright (c) SuSE GmbH Nuernberg

# There are 3 different types of shells in bash: the login shell, normal shell
# and interactive shell. Login shells read ~/.profile and interactive shells
# read ~/.bashrc; in our setup, /etc/profile sources ~/.bashrc - thus all
# settings made here will also take effect in a login shell.
#
# NOTE: It is recommended to make language settings in ~/.profile rather than
# here, since multilingual X sessions would not work properly if LANG is over-
# ridden in every subshell.

# Some applications read the EDITOR variable to determine your favourite text
# editor. So uncomment the line below and enter the editor of your choice :-)
#export EDITOR=/usr/bin/vim
#export EDITOR=/usr/bin/mcedit

# For some news readers it makes sense to specify the NEWSSERVER variable here
#export NEWSSERVER=your.news.server

# If you want to use a Palm device with Linux, uncomment the two lines below.
# For some (older) Palm Pilots, you might need to set a lower baud rate
# e.g. 57600 or 38400; lowest is 9600 (very slow!)
#
#export PILOTPORT=/dev/pilot
#export PILOTRATE=115200

export PATH=$(JAVA_HOME)bin:$(jdk1.7.0_09)

test -s ~/.alias && . ~/.alias || true
~                                                                              
~                                                                              
~                                                                              
~                                                                              
~
Ignore the previous post.  This is the file.  Sorry, thanks.


# Sample .bashrc for SuSE Linux
# Copyright (c) SuSE GmbH Nuernberg

# There are 3 different types of shells in bash: the login shell, normal shell
# and interactive shell. Login shells read ~/.profile and interactive shells
# read ~/.bashrc; in our setup, /etc/profile sources ~/.bashrc - thus all
# settings made here will also take effect in a login shell.
#
# NOTE: It is recommended to make language settings in ~/.profile rather than
# here, since multilingual X sessions would not work properly if LANG is over-
# ridden in every subshell.

# Some applications read the EDITOR variable to determine your favourite text
# editor. So uncomment the line below and enter the editor of your choice :-)
#export EDITOR=/usr/bin/vim
#export EDITOR=/usr/bin/mcedit

# For some news readers it makes sense to specify the NEWSSERVER variable here
#export NEWSSERVER=your.news.server

# If you want to use a Palm device with Linux, uncomment the two lines below.
# For some (older) Palm Pilots, you might need to set a lower baud rate
# e.g. 57600 or 38400; lowest is 9600 (very slow!)
#
#export PILOTPORT=/dev/pilot
#export PILOTRATE=115200

export PATH=$(JAVA_HOME)/bin:$(jdk1.7.0_09)
#export JAVA_HOME=/home/al/jdk1.7.0_05

test -s ~/.alias && . ~/.alias || true
~                                                                              
~                                                                              
~                                                                              
~                                                                              
~
Mine:
export PATH=${JAVA_HOME}/bin:${PATH}

Open in new window

Yours:
export PATH=$(JAVA_HOME)/bin:$(jdk1.7.0_09)

Open in new window


In addition to the bracket type being wrong in yours, it also doesn't make any sense. Note, mine will only work if JAVA_HOME has been set before that
Now that I get out my spy glass I see the bracket rather than the paren.  I'll see what that does.  Thanks.
Thanks for hangin' in there.
:)