Link to home
Start Free TrialLog in
Avatar of jpegvarn
jpegvarnFlag for United States of America

asked on

Java 1.1.8 on FreeBSD support -jar???

Hello,

I've been testing a script which using "java -jar filename" and creates output on my machine and works fine with the latest version of Java.  However, the live server is FreeBSD with the latest support version of Java, which is 1.1.8.  It appears that I cannot use the "java -jar" command and specifiy the jar file I need to use with this version...Is this true or is there a workaround???  Any help would be greatly appreciated...I couldn't find much with a google search.
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

You'd probably have to unjar the file
jar -xvf yourjar.jar

java x.y.z.MainClass
can't you just do:

java -cp yourjar.jar x.y.z.MainClass

?
>>can't you just do ...

Certainly give that a try. I'm wondering if that version supports jars even in that way
True...  I'm pretty sure 1.1.8 supported jars on the classpath... it's the BSD bit I'm not sure about ;-)
Avatar of jpegvarn

ASKER

The accepted answer seems correct.  Thank you!
fyi - I wrote 'seems' because there are a couple loop holes I have to go through to get my final result.  Thanks again!
did you try my suggestion?  It might save you expanding the jar file...
TimYates & All,

Please see: https://www.experts-exchange.com/questions/21177048/Java-1-1-8-on-FreeBSD-support-jar-PART2.html

I made a mistake and there is another 500 points to be rewarded.  Thank you.
500 points is the maximum for a question
I asked Venabilli to reopen this Q.
Thank you, please inform me when it is re-opened.
java -classpath yourjar.jar x.y.z.MainClass

should work then :-)

Tim
Question reopened:)
I am also deleting the other question.

Venabili
Java Page Editor
Avatar of brunomsilva
brunomsilva

please give us the output error return by the answer provided by CEHJ so we can have an idea of the problem.

bruno
Thank you.

TimYates - when I run that, I am getting "Unable to initialize threads: cannot find class java/lang/Thread" .  Do you have an idea what this error means?

brunomsilva - when I ran CEHJ's suggestion, I am getting "-cp: illegal argument" .

Usage: java [-options] class

where options include:
    -help             print out this message
    -version          print out the build version
    -v -verbose       turn on verbose mode
    -debug            enable remote JAVA debugging
    -noasyncgc        don't allow asynchronous garbage collection
    -verbosegc        print a message when garbage collection occurs
    -noclassgc        disable class garbage collection
    -cs -checksource  check if source is newer when loading classes
    -ss<number>       set the maximum native stack size for any thread
    -oss<number>      set the maximum Java stack size for any thread
    -ms<number>       set the initial Java heap size
    -mx<number>       set the maximum Java heap size
    -D<name>=<value>  set a system property
    -classpath <directories separated by colons>
                      list directories in which to look for classes
    -prof[:<file>]    output profiling data to ./java.prof or ./<file>
    -verify           verify all classes when read in
    -verifyremote     verify classes read in over the network [default]
    -noverify         do not verify any class
Replace "-cp" with "-classpath"
;°)
TimYates - when I run "java -classpath filename.jar x.y.z.MainClass filename.xml filename.xsl", I am getting "Unable to initialize threads: cannot find class java/lang/Thread" .
And to fix the: "Unable to initialize threads:" error, you need to make sure that classes.zip (in the java dir) is in the classpath too...

does:

java -classpath yourJar.jar:/path/to/java/classes.zip x.y.z.MainClass

work any better?
Java before 1.3 was a pain with the classpath...

"Unable to initialize threads: cannot find class java/lang/Thread" was the first message most java programmers ever saw ;-)
Tim, didn't you mean

     java -classpath yourJar.jar;c:/path/to/java/classes.zip x.y.z.MainClass

?
Windows uses ; Unix uses :

go figure ;-)
"Can't find class x.y.z.MainClass"

Any idea on this?  Could I possibly be using a wrong classes.zip?  I checked inside the zip an do not see an x.y.z.MainClass, but there is a Main.class.
x.y.z.MainClass was just an example
AH!  What class should I be using then?  I have no idea.
>> there is a Main.class
And if that class is in a path  \xxx\yyy

then replace x.y.z.MainClass by  xxx.yyy.Main
what is your main class?

The class that is "Main-class" in the /META-INF/Manifest.mf in the jar file itself...
(it is the class with "public static void main( String[] args )" in it :-)
>> What class should I be using then?
the "main" class in your jar file
:)
Okay, I think I'm getting closer.  Here is exactly what I am executing (I've tried both and many more), but I am getting this: "Unable to initialize threads: cannot find class java/lang/Thread"  The com.icl.saxon.StyleSheet.java is in the source.zip file under /com/icl/saxon/ folder.

/usr/local/jdk1.1.8/bin/java -classpath ./saxon/saxon.jar com.icl.saxon.StyleSheet newfile.xml 2excel.xsl

/usr/local/jdk1.1.8/bin/java -classpath ./saxon/saxon.jar:./saxon/source.zip com.icl.saxon.StyleSheet newfile.xml 2excel.xsl

/usr/local/jdk1.1.8/bin/java -classpath ./saxon/saxon.jar:./saxon/source.zip com.icl.saxon.StyleSheet.java newfile.xml 2excel.xsl
java -classpath ./saxon/saxon.jar:classes.zip com.icl.saxon.StyleSheet newfile.xml 2excel.xsl
ASKER CERTIFIED SOLUTION
Avatar of TimYates
TimYates
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
You'll probably be better off setting some environment variables first (allowing for your particular shell):

CLASSPATH=/usr/local/jdk1.1.8/lib/classes.zip;
PATH=/usr/local/jdk1.1.8/bin:$PATH
.......

java  -classpath $CLASSPATH:./saxon/saxon.jar com.icl.saxon.StyleSheet newfile.xml 2excel.xsl

but it's *essential* you get those paths 100% right
The main problem was I had to use the full path to every file in the script.  Thanks.
>>The main problem was I had to use the full path to every file in the script

Not quite sure how the single accepted answer tallies with that comment jpegvarn ...