Results 1 to 4 of 4
I don't know the first thing about Java... so this should be easy for those of you who have a handle on the basics...
Are .jar files portable across different ...
- 10-26-2007 #1Just Joined!
- Join Date
- May 2007
- Location
- seattle
- Posts
- 16
Java: Are jar files portable?
I don't know the first thing about Java... so this should be easy for those of you who have a handle on the basics...
Are .jar files portable across different flavors of Linux?
I have inherited a bunch of scripts. Some of them employ these .jar files, and they're apparently binaries. Anyhow... they were running on a SuSe box, and I'm doing the Fedora thing. I'm also changing hardware, from a desktop, intel based PC, to a intel based rack-mount server.
I don't know where the source that created these files is... am I just screwed? Or should the .jar files run?
If so, is there a quick way I can make these scripts compatible, or am I gonna find that I'm missing a whole assortment of libraries and attachments and dlls or whatever the equivalent in java is... for such stuff... that in the end makes an OS platform dependent?
--Ray
- 10-26-2007 #2
Yes. JAR files are portable across any operating system that has a Java Virtual Machine, so that includes all flavors of Linux, Solaris, Mac OS X, MS Windows, and some flavors of UNIX.
If the person that created the JAR files included all the proper classes, your JAR files should be self-contained and run on pretty much any platform the same way.Registered Linux user #270181
TechieMoe's Tech Rants
- 10-26-2007 #3Just Joined!
- Join Date
- May 2007
- Location
- seattle
- Posts
- 16
drat. I was afraid you were gonna say that...
Now I have to figure out how to make it work.
How does one go about getting libs and such in the realm of Java? I don't imagine they have a nice auto-dependency checking library grabbing thingie, like perl -MCPAN -e shell?
--Ray
- 10-27-2007 #4
Well, let's first examine what a JAR file is. This should help you understand what's going on.
A JAR file is basically just an archive. It contains a number of .class files. A .class file is a compiled Java source file. Java does not compile into machine code: rather, it compiles into Java bytecode. This bytecode is read by the Java Virtual Machine, and the JVM translates it into the local machine code at execution. This is why Java is portable: compiled Java is not actually compiled specifically for any architecture.
So when you run your JAR file, the Java interpreter looks at the manifest, which contains some information about the archive. In particular, it contains the "Main-Class" entry, which specifies what class to begin the execution with.
So now, when you run the JAR file, it will run. It may print out errors of many, many sorts. If there are problems with libraries, the problem will most likely involve missing class definitions. It should specify a class such as "com.javalibraries.AwesomeLib". This generally means the "AwesomeLib" class, developed at "javalibraries.com" (according to the official naming scheme). Assuming that that doesn't work, you could try Googling for the class name to find out what library it is a part of, and installing it.
Fortunately, most of Java's capabilities are included in the standard library (which is enormous), so you probably won't need many external libraries. But see if this helps, and if it's a different error you're getting, maybe you can post it here?DISTRO=Arch
Registered Linux User #388732


Reply With Quote
