jpegvarn
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.
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.
You'd probably have to unjar the file
jar -xvf yourjar.jar
java x.y.z.MainClass
java x.y.z.MainClass
I read at http://java.sun.com/j2se/1.4.2/docs/api/java/util/jar/package-summary.html:
Since: version 1.2
Since: version 1.2
can't you just do:
java -cp yourjar.jar x.y.z.MainClass
?
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
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 ;-)
ASKER
The accepted answer seems correct. Thank you!
ASKER
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...
ASKER
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.
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.
I asked Venabilli to reopen this Q.
ASKER
Thank you, please inform me when it is re-opened.
java -classpath yourjar.jar x.y.z.MainClass
should work then :-)
Tim
should work then :-)
Tim
Question reopened:)
I am also deleting the other question.
Venabili
Java Page Editor
I am also deleting the other question.
Venabili
Java Page Editor
please give us the output error return by the answer provided by CEHJ so we can have an idea of the problem.
bruno
bruno
ASKER
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
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"
;°)
ASKER
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.zi p x.y.z.MainClass
work any better?
does:
java -classpath yourJar.jar:/path/to/java/
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 ;-)
"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/jav a/classes. zip x.y.z.MainClass
?
java -classpath yourJar.jar;c:/path/to/jav
?
Windows uses ; Unix uses :
go figure ;-)
go figure ;-)
ASKER
"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.
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
ASKER
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
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...
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
the "main" class in your jar file
:OP
:)
ASKER
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.j ava is in the source.zip file under /com/icl/saxon/ folder.
/usr/local/jdk1.1.8/bin/ja va -classpath ./saxon/saxon.jar com.icl.saxon.StyleSheet newfile.xml 2excel.xsl
/usr/local/jdk1.1.8/bin/ja va -classpath ./saxon/saxon.jar:./saxon/ source.zip com.icl.saxon.StyleSheet newfile.xml 2excel.xsl
/usr/local/jdk1.1.8/bin/ja va -classpath ./saxon/saxon.jar:./saxon/ source.zip com.icl.saxon.StyleSheet.j ava newfile.xml 2excel.xsl
/usr/local/jdk1.1.8/bin/ja
/usr/local/jdk1.1.8/bin/ja
/usr/local/jdk1.1.8/bin/ja
java -classpath ./saxon/saxon.jar:classes. zip com.icl.saxon.StyleSheet newfile.xml 2excel.xsl
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You'll probably be better off setting some environment variables first (allowing for your particular shell):
CLASSPATH=/usr/local/jdk1. 1.8/lib/cl asses.zip;
PATH=/usr/local/jdk1.1.8/b in:$PATH
.......
java -classpath $CLASSPATH:./saxon/saxon.j ar com.icl.saxon.StyleSheet newfile.xml 2excel.xsl
but it's *essential* you get those paths 100% right
CLASSPATH=/usr/local/jdk1.
PATH=/usr/local/jdk1.1.8/b
.......
java -classpath $CLASSPATH:./saxon/saxon.j
but it's *essential* you get those paths 100% right
ASKER
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 ...
Not quite sure how the single accepted answer tallies with that comment jpegvarn ...