United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: 4138619 Solaris is unable to exec() executable jar files
4138619 : Solaris is unable to exec() executable jar files

Details
Type:
Bug
Submit Date:
1998-05-14
Status:
Closed
Updated Date:
1999-01-19
Project Name:
JDK
Resolved Date:
1999-01-19
Component:
core-libs
OS:
solaris_2.6
Sub-Component:
java.lang:class_loading
CPU:
generic
Priority:
P2
Resolution:
Fixed
Affected Versions:
1.2.0
Fixed Versions:
1.2.0

Related Reports
Relates:
Relates:
Relates:

Sub Tasks

Description
 Following PSARC/1997/123, the solaris exec() mechanism was updated to provide
 for executing jar executables.

 The 1.2 documentation at:
   http://java.sun.com/products/jdk/1.2/docs/guide/extensions/spec.html#javacmd

 indicates that a Manifest entry of Main-Class will create an executable jar
 file and:

  The Solaris 2.6 kernel has already been extended to recognize the special
  "magic" number that identifies a JAR file, and to invoke java -jar on such
  a JAR file as if it were a native Solaris executable. A Java application
  packaged in a JAR file can thus be executed directly from the command line
  or by clicking an icon on the CDE desktop.

 Although the Main-Class entry creates a jar executable suitable for use with
 java -jar:

	% javac HelloWorld.java

	% cat  META-INF/MANIFEST.MF
	Manifest-version: 1.0
	Main-Class: HelloWorld
	Name: HelloWorld.class

	% jar -native -cvmf META-INF/MANIFEST.MF HelloWorld HelloWorld.class
	adding: HelloWorld.class (in=472) (out=316) (deflated 33%)
	
	% java -native -new -jar HelloWorld
	Hello world!

 This file can not be executed directly:

	% chmod +x HelloWorld
	% HelloWorld
	./HelloWorld: syntax error at line 1: `)' unexpected

 truss(1) reveals:

 609:    execve("./HelloWorld", 0x00052948, 0x00052950)  Err#8 ENOEXEC


                                    

Comments
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
generic

FIXED IN:
1.2beta4

INTEGRATED IN:
1.2beta4

VERIFIED IN:
1.2beta4


                                     
2004-06-14
EVALUATION

	The creation of an execution jar file with a Main-Class is not inserting
	the LOCEXT entry required by the kernel to identify this file.

	Using a test file I was able to get it execed by adding an intermediate 
	exec routine (presently the args necessary require -new).  So, what we 		
	have is:
 
 	% /usr/java/lib/jexec -> /home/rie/java/jarexec/jexec
 	% cat jexec.c
 	#include <unistd.h>
 
 	main(int argc, char * argv[], char * envp[])
 	{
 	        execle("/usr/java1.2e/bin/sparc/java",
 	                argv[0], "-new", argv[1], argv[2], 0, envp);
 	}
 	% ./x.jax
 	hello
 	
	This jar file has a LOCEXT value that allows us to find the magic
	java executable signature.
 
	oxpoly 499.. od -x ./x.jax +. | head -16
	0000000 504b 0304 1400 0800 0800 2806 be22 0000
	0000016 0000 0000 0000 0000 0000 1400 0300 4d45
	                                 ^^             LOCNAM -> byte 50
	                                      ^^        LOCEXT == 3 
	0000032 5441 2d49 4e46 2f4d 414e 4946 4553 542e
	0000048 4d46 feca 00f3 4dcc cb4c 4b2d 2ed1 0d4b
	             ^^^^^^^ 
	#define XFJAVASIG       0xcafe          /* java executables */ 
 
	Presently a jar file created using jar with a Main-Class entry point:

	oxpoly 503.. od -x ./HelloWorld +. | head -16
	0000000 504b 0304 1400 0800 0800 aa72 ad24 0000
	0000016 0000 0000 0000 0000 0000 1400 0000 4d45
	                                 ^^             LOCNAM -> byte 50
	                                      ^^        LOCEXT == 0 
	0000032 5441 2d49 4e46 2f4d 414e 4946 4553 542e
	0000048 4d46 f34d cccb 4c4b 2d2e d12d 4b2d 2ace
	             ^
	             The three bytes containing cafe are missing.
---- Rod Evans ---

The JAR tool has been fixed for 1.2Beta4 to add the appropriate magic
number to the extra field data for the first JAR entry. The only difference
is that magic number will be added to all JAR files, not just executable
ones. The java interpreter will display an error if the JAR file does not
contain a "Main-Class" manifest attribute. This change was made in order
to simplify JarOutputStream as otherwise it would be difficult to determine
if the JAR file is executable unless the manifest was specified in advance.

david.connelly@Eng 1998-05-19

varified with recompiled jexec.c
                                     
1998-05-19



Hardware and Software, Engineered to Work Together