Java and Javac problems

Ok need some help getting Java working I have the JRE JDK as well as the Netbeands IDE installed. But still having issues getting java and javac working from command line. Running Solaris 11 64 box.

root@solaris:/usr/jdk/instances/jdk1.7.0/bin# dir
amd64         javadoc     jsadebugd       rmiregistry
appletviewer     javah         jstack       schemagen
apt         javap         jstat       serialver
ControlPanel     javaws      jstatd       servertool
extcheck     jconsole    jvisualvm       tnameserv
HelloWorld.java  jcontrol    keytool       unpack200
idlj         jdb         native2ascii  wsgen
jar         jhat         orbd       wsimport
jarsigner     jinfo         pack200       xjc
java         jmap         policytool
java-rmi.cgi     jps         rmic
javac         jrunscript  rmid
root@solaris:/usr/jdk/instances/jdk1.7.0/bin# javac HelloWorld.java 
bash: javac: command not found
root@solaris:/usr/jdk/instances/jdk1.7.0/bin# 

next issue would be setting the PATH variable so I can use the javac and java command from any folder. When ever I set the Path it is gone after I close the terminal. Thank you for any explanation about whats going on.

javac is NOT in your path so use

root@solaris:/usr/jdk/instances/jdk1.7.0/bin# ./javac HelloWorld.java

Place in your login directory [ .profile ] or in /etc/profile if all users need javac:

#below any PATH defining statements
PATH=${PATH}:/usr/jdk/instances/jdk1.7.0/bin
export PATH

I wrote the export on another line deliberately. This is Solaris so we use Borune syntax in case this is placed in /etc/profile

Comment:
Under no circumstances should you be running around on the system as the root user. It is dangerous, plus you seem to be new with what you are doing. Two reasons to create an unprivileged user and play with that.

You do have really frequent backups, right? An you enjoy re-installing your system?
Both will be needed if you keep on "root"-ing around.

Actually, export PATH=${PATH}:/usr/jdk/instances/jdk1.7.0/bin would be fine as this is Solaris 11 where /bin/sh is ksh93 while the legacy Bourne shell (/usr/sunos/bin/sh) is very unlikely to be set as a login shell.

In any case, export is superfluous as the PATH variable is already exported at the beginning of the /etc/profile script and even before it is called actually.

Ok got the path variable set. I typically dont root around but thanks for the advice on that, now I have a backup folder I copy files to rename one to fileold and edit the other so I can revert to fileold if new file screwed up things which I intent to do :slight_smile: Now I have a few more issues. Now that path variable is set and works when I execute java HelloWorld I recieve unsupported major.minor version error. I use gedit to write code. From what I have read its telling me I created a file in version 1.7 however version 1.6 is trying to run the program, creating a reverse compatibilty issue. pkg list shows both 1.6 and 1.7 in the runtime. Do I need to uninstall 1.6 and the --- in package list, if an i is listed it represents that its installed what are the other --.

That is an LD_LIBRARY_PATH issue. If your PATH has the new java directory BEFORE /usr you
are ok. find the ./lib directory under the new directory. Let's pretend it came out out as
usr/jdk/instances/jdk1.7.0/

Then in your code script to run your new java code try:

export LD_LIBRARY_PATH=usr/jdk/instances/jdk1.7.0/:${LD_LIBRARY_PATH}

Ok everytime I make some progress more is piled on top. However what is piled on top is more jiberess. Its obvious Im new to Unix. If this was windows the program would be installed and usable, done thats it. I would like to make this work, more I would like to understand why its not working. First its an Path issue now its a LD_Library_Path issue. Sorry folks this has been a week of try this do that ect with no explanation. So can anyone point me to the logic behind it all, I mean theres has to be some kind structure yes?

Windows is derived from UNIX, and has an interface that will not let you see most of what is underneath, without expensive tools or lots of knowledge. Solaris does not have that. Plus it looks like you may have done some kind of non-standard install of java.

Consider this carefully:

Put Solaris on hold for a few months.

Use Windows to run interference for you until you are a lot more comfortable with base UNIX.

Here is what I would do. Download and Install cygwin. You install it as an add on to Windows. I have a copy of UNIX as cygwin on my work desktop computer, it is useful.

Cygwin

Everytime you want a piece of software for cygwin, the download lets the installer put it up for you. Just like Windows. And it is all free. Not like Windows. This way it is harder to shoot yourself in the foot.

After you play with cygwin for a while, consider installing a dual boot of Ubuntu on the same windows box. Ubuntu (a kind of Linux) is meant for transitioning from Windows to UNIX. Solaris is very much not meant for that. The motivation for Ubuntu was to make it really simple for Windows users to avail themselves of the huge opensource software selection. If you are really computer conversant, go straight to Ubuntu if you want.

I manage 4 $100K Solaris M4000 boxes, each with about a dozen virtual computers (zones) in them which is 48 Solaris computers. I've been doing UNIX since the late 1970's and still encounter stuff I do not know. Cygwin/Ubuntu is made to isolate the user from all that.

So change course for a while. If you don't like my idea you will have to do a lot of learning, reading, and fiddling before your frustration level with Solaris goes away.

1 Like

What makes you feel it is ?
LD_LIBRARY_PATH is unset by default under Solaris and should stay that way unless inside specific wrapper scripts.

This is both incorrect (you are missing a leading slash) and useless (there are no libraries in the jdk1.7.0 directory).

---------- Post updated at 15:06 ---------- Previous update was at 15:01 ----------

Sure there is a structure.
If you want the jdk1.7 to be your default java environment, just put both of these lines in your .profile or .bash_profile

PATH=/usr/jdk/instances/jdk1.7.0/bin:$PATH
export JAVA_HOME=/usr/jdk/instances/jdk1.7.0

logout and login again and you are set.

---------- Post updated at 15:21 ---------- Previous update was at 15:06 ----------

Windows has very little in common with Unix and is quite unlikely to include anything derived from Unix code outside some tcp/ip utilities borrowed from BSD.

I disagree - not that it really matters.

DOS was developed on XENIX and borrowed a lot of the underlying architecture.
Windows - up until NT - was completely layered on top of DOS 16 bit. The NT kernel continued some of UNIX-derived stuff. As WOW. I has all gone away with Windows 7.

And you are correct about JAVA_HOME. I though the OP had set it. The install seemed to be odd.

But. The point was that Solaris requires UNIX knowledge, windows requires almost no knowledge about what is going on behind the scenes. Windows power users are really well-advised to use cygwin or something like ubuntu, not Solaris, as a first time jaunt into UNIX.

Ill advised off topic post follows:

Isn't NT based on VMS? with the BSD network stack?

That depends on how you define "based on".
Microsoft hired one of the VMS main architects (David Neil Cutler) to redesign Windows and Windows NT was the result. NT was actually a pun: you add +1 to each letter of VMS and you get WNT.

Unlikely to have the whole BSD network stack but some parts of it was based on BSD licensed code. Nowadays, I guess only things like ftp, tracert and the likes might still have BSD code. See this page for details.

---------- Post updated at 18:48 ---------- Previous update was at 17:50 ----------

"borrow" is lighter than "derived from" so DOS might indeed have borrowed some Unix concepts, although I would state it really borrowed most of its design from CP/M. XENIX, originally a Unix version 7 implementation, was already a multi-task, multi-user OS with a single hierarchical file system. DOS was definitely missing all of these features.

Got it. You confused LD_LIBRARY_PATH and JAVA_HOME.

1 Like

This is where my points about the origins and development of DOS come from:
XENIX -- Microsoft Short-lived Love Affair with Unix

What this huge page says in small part:
Basically from 1980 - after DOS had been put together - DOS and XENIX started on toward full compatibility. A lot of xenix was brought into DOS as memory and disk become available for machines in the early 1980's.

To be correct DOS started with Altair.