LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 11-09-2004, 09:18 PM   #1
woranl
Member
 
Registered: Apr 2003
Location: Toronto
Distribution: Fedora Core
Posts: 119

Rep: Reputation: 15
Question 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?

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
 
Old 11-09-2004, 10:05 PM   #2
CroMagnon
Member
 
Registered: Sep 2004
Location: New Zealand
Distribution: Debian
Posts: 900

Rep: Reputation: 33
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
 
Old 11-09-2004, 10:12 PM   #3
foo_bar_foo
Senior Member
 
Registered: Jun 2004
Posts: 2,553

Rep: Reputation: 51
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Java Programming: Java Runtime Environment not found when trying to compile murbz Linux - Software 2 03-26-2009 03:04 AM
How to run a java jar file. sabliny Programming 7 11-05-2005 01:59 PM
How jar java program? treotan Programming 3 09-08-2005 12:03 AM
Fedora Core 1 Associating .jar files with java -jar command pymehta Fedora 0 01-13-2005 05:26 AM
Mandrake and the command java -jar silent1_22 Linux - Distributions 3 11-23-2002 06:25 AM


All times are GMT -5. The time now is 03:26 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration