LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Compile Java - .class, .java, .jar ? (https://www.linuxquestions.org/questions/programming-9/compile-java-class-java-jar-253043/)

woranl 11-09-2004 09:18 PM

Compile Java - .class, .java, .jar ?
 
Hi all,

This should be an easy question for you guy, please help.

Currently, I'm building a website, which allow my visitors to upload files by drag & drop.

I found JUpload ( the GPL version at http://sourceforge.net/projects/jupload/ )
and I'm able to set it up under Windows. My goal is to use this Java applet on Linux.

I don't know anything about JAVA and I don't know how to compile the JAVA source code. Inside the "src" folder, there are several .java files. I tried to use "javac" and some of the .java files were able to turn into .class files and some could not (for some reason)

My question is.. for the binary applet that I downloaded, it is in .jar format. How do I make a .jar file from all those .class files??

What is .class and .jar anyway?:study:

In general how do I compile a JAVA applet? What tools do I need?

Do I really need to recompile the applet? Can the same applet work in both Windows and Linux OS?

Please help this JAVA newbie :newbie:

CroMagnon 11-09-2004 10:05 PM

Quote:

My question is.. for the binary applet that I downloaded, it is in .jar format. How do I make a .jar file from all those .class files??
You can do this with the jar command (it is very similar to the tar command - just type jar to see what options it has). Quick and dirty sample:
jar cf myjar.jar *.class

Quote:

What is .class and .jar anyway?
.class is the java bytecode file for a single object (also called a class...). .jar is just a convenient package for more than one class file. Think "java archive".

Quote:

In general how do I compile a JAVA applet? What tools do I need?
You need either gcj (the gnu java compiler) or a JDK (there are a few to choose from).

Quote:

Do I really need to recompile the applet? Can the same applet work in both Windows and Linux OS?
In theory there is no need to recompile. In practice, some people write java that is not portable. The only way to know for sure is to try and run it under linux and test, test, test :(

foo_bar_foo 11-09-2004 10:12 PM

jar is a java archive like tar
.class is a compiled java source .java file and the name i guess is a reflection of the object oriented nature of java
"class" is an OO structure introduced in c++

you do not need to recompile the applet the same applet will work on all platforms or if it won't it needs rewriting not recompile.

no need to put applets in jars really take a look at the examples in you jdk

to make an executable .jar archive (see java docs or look at an exaple manifest file)
jar cmf manifest.mf myJar.jar *.class


All times are GMT -5. The time now is 05:20 PM.