Java and Javac problems


 
Thread Tools Search this Thread
Operating Systems Solaris Java and Javac problems
# 1  
Old 10-11-2012
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.

Code:
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.
Moderator's Comments:
Mod Comment code tags please

Last edited by jim mcnamara; 10-11-2012 at 09:31 PM..
# 2  
Old 10-11-2012
javac is NOT in your path so use
Code:
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:
Code:
#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.
# 3  
Old 10-12-2012
Quote:
Originally Posted by jim mcnamara
Code:
#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 Bourne syntax in case this is placed in /etc/profile
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.
# 4  
Old 10-12-2012
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 Smilie 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 --.
# 5  
Old 10-12-2012
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:
Code:
export LD_LIBRARY_PATH=usr/jdk/instances/jdk1.7.0/:${LD_LIBRARY_PATH}

# 6  
Old 10-12-2012
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?
# 7  
Old 10-13-2012
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.

http://www.ubuntu.com/download/desktop

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.
This User Gave Thanks to jim mcnamara For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

3 More Discussions You Might Find Interesting

1. Programming

set javac classpath

I have several jar files in a specific folder, but I can't get javac to understand it. How do I set the classpath for javac. It is NOT the same classpath as the java command. And it's not enough with one jar file. I have several. (1 Reply)
Discussion started by: locoroco
1 Replies

2. UNIX for Dummies Questions & Answers

Installing Java Problems

Hello, When i attempt to install Java. I get this error code Can someone tell me what im doing wrong. (2 Replies)
Discussion started by: Fob Upset
2 Replies

3. UNIX for Dummies Questions & Answers

piping with javac command

how to i use javac on a file after searching for it? example: find . -name '*.java' -size -24 -links -2 -atime -4 what would happen if "find" found >1 .java files? also, i'm a little confused on the -size property... mix up between -2 and +2... what's the difference? (1 Reply)
Discussion started by: quipy
1 Replies
Login or Register to Ask a Question