How to avoid "cannot execute" issue with a runnable jar file?


 
Thread Tools Search this Thread
Operating Systems Solaris How to avoid "cannot execute" issue with a runnable jar file?
# 1  
Old 11-20-2011
How to avoid "cannot execute" issue with a runnable jar file?

I am trying to understand why the runnable jar file runs on one Unix server, but not the other with same environment settings.

I copied exact same test jar from here -->
http://www.javaworld.com/javaworld/javatips/javatip127/MakeJarRunnable.zip

on to both Unix servers. Then changed permission on the jar to have execute permission to user.

I am able to execute it on serverA. But on serverB it fails. I checked JDK version, ksh version, tty, path, classpath settings all of them are same on both servers. It does not appear to be a DOS end-of-line character issue with manifest file. I am able to execute a test.sh script that has a simple echo with ^M character at the end of line with just -> $>./test.sh on both servers.

Code:
 
serverA/$>./myjar_r.jar
ksh: ./myjar_r.jar: cannot execute
 
-rwxr-----   1 xxx   yyyy     705 Nov 19 21:55 myjar_r.jar
 
serverA/$>Version M-11/16/88i
 
serverB/$>./myjar_r.jar
Hello, Runnable World!
 
serverB/$>Version M-11/16/88i

Could you try to execute that jar on your end and see if you could figure out what could cause it not to execute?

BlackDog: Programming => Tips => JAR run

http://www.javaworld.com/javaworld/j...arRunnable.zip

Last edited by kchinnam; 11-20-2011 at 01:34 AM.. Reason: spelling
# 2  
Old 11-21-2011
What systems are ServerA and ServerB?

I wouldn't have expected JAR files to be directly runnable on any UNIX system. They execute files based on header bytes, not file extension associations.
# 3  
Old 11-21-2011
serverA, serverB both are running Solaris8, JDK1.4.2_04.

Yes general understanding is you can't execute jar files directly. But that is not true from JDK1.2 on words, apparently both windows and Unix do recognize .jar associated with java and execute the class with main method specified in manifest file.
This article explins how that happens..> http://www.javaworld.com/javaworld/j...27.html?page=1

I also gave proof in my post that "myjar_r.jar" jar file is getting executed on serverB, but not on serverA.
Since test jar file is available on the net, anyone can test it.

I did check other things like how Unix file associations work using -->
/etc/magic,
/usr/dt/appconfig/types/C/datatypes.dt. I did check if this has something do with PATH, CLASSPATH settings or tty setting etc.. Bu all these settings look same on both servers.
That is why this problems looks very interesting and challenging.

Last edited by kchinnam; 11-21-2011 at 12:58 PM.. Reason: added more info
# 4  
Old 11-21-2011
Proving serverb runs it while servera can't without actually saying what they are isn't too useful, serverb could have been a windows machine running jars in cygwin for all I knew -- which I actually suspected because you linked Windows instructions as if they were relevant...

Knowing you have solaris is good, and makes sense to a degree. You'd expect a Sun OS to support Java if anything did.

I know for a fact it doesn't work on my Linux system but that's not at all relevant. Linux isn't Solaris. Getting it working in mine would probably mean playing with "MISC binary support" in the kernel.

You might want to get this moved to the Solaris forum so people who know Solaris internals notice this.
# 5  
Old 11-21-2011
How can I move this thread to Soarlis Forum?
# 6  
Old 11-21-2011
moved.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

2. Shell Programming and Scripting

How to avoid "Too many arguments" error, when passing a long String literal as input to a command?

Hi, I am using awk here. Inside an awk script, I have a variable which contains a very long XML data in string format (500kb). I want to pass this data (as argument) to curl command using system function. But getting Too many arguments error due to length of string data(payloadBlock). I... (4 Replies)
Discussion started by: cool.aquarian
4 Replies

3. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

4. Shell Programming and Scripting

How to avoid "override protection 644 (yes/no)?" -ksh 88

Hi All, I'm using Ksh 88 version. I'm trying to remove the files using the below script .The code is working fine but i'm getting override protection 644 (yes/no)? message for every file .. Pelase suggest #!/usr/bin/ksh set -x File_Path="/etc/home/logs" Dest_Path="/etc/home/temp"... (1 Reply)
Discussion started by: smile689
1 Replies

5. Shell Programming and Scripting

Want to write all the jar name in single with delimiter ":" in beween the jar name

Hi All, I am having 7 jar files in a dir. abc like listed below bash-3.00$ cd abc bash-3.00$ ls 123.jar 23wdawd.jar dfsa23.jar dsa.jar wew234.jar adsd234234.jar dfsda423.jarNow i want to assign all this jar files to a variable in the below format ... (6 Replies)
Discussion started by: natraj005
6 Replies

6. Shell Programming and Scripting

""Help Me!""Beginner awk learning issue

Hi All, I have just now started learning awk from the source - Awk - A Tutorial and Introduction - by Bruce Barnett and the bad part is that I am stuck on the very first example for running the awk script. The script is as - #!/bin/sh # Linux users have to change $8 to $9 awk ' BEGIN ... (6 Replies)
Discussion started by: csrohit
6 Replies

7. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

8. Shell Programming and Scripting

Execution problems with the jar -tvf command and "if" logic

Hi, I am reading a directory that has a list of jar files. I am searching these files for specific keywords. What i would like to do is write the address of the jar file to a new file if the search result is returned as false. For example; /home/user/JarDirectory/Examplefile.jar ... (2 Replies)
Discussion started by: crunchie
2 Replies

9. Shell Programming and Scripting

Joining 3 AWK scripts to avoid use "temp" files

Hi everyone, Looking for a suggestion to improve the below script in which I´ve been working. The thing is I have 3 separated AWK scripts that I need to apply over the inputfile, and for scripts (2) and (3) I have to use a "temp" file as their inputfile (inputfile_temp and inputfile_temp1... (2 Replies)
Discussion started by: cgkmal
2 Replies

10. Shell Programming and Scripting

Avoid "++ requires lvalue" Error in Loop Calculation

Hi All, Please help me to perform sum of values in a loop, I am getting following error: "total=0++432907765772: ++ requires lvalue" where actual statement is as : total=$total+$amt where amt can have +ve or -ve values Thanks Sandeepb (3 Replies)
Discussion started by: sandeepb
3 Replies
Login or Register to Ask a Question