LinuxQuestions.org
Review your favorite Linux distribution.
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 05-05-2007, 10:30 AM   #1
me4linux
Member
 
Registered: Aug 2006
Distribution: Fedora 7
Posts: 165

Rep: Reputation: 30
Start to run Java Programs in fedora core 6


Hi everyone

I have installed fedora core 6.
java, javac , javap , javaws commands are available in my system...
i have also installed netbeans 5.5
Cany any one please tell me how to run a jav program..
I have set the environment variable $JAVA_HOME

-----
javac filename.java
java
-----

with these commands can i run any java program [excluding servlets ....]
any java program i mean program with applets

Is netbeans necessary for simple programs and concepts that a beginner of java is suppposed to learn...?

I am a beginner of java ...I have to start it soon in a couple of weeks since i am busy with some work

Does the commands javac and java are enough for me to run java programs

Do I need to install/set any environmental variables ......etc??

Please help me to start using java in fedora core 6

Please post small tutorial on HOW TO RUN JAVA PROGRAMS IN FEDORA [ANY LINUX]
I think it will be useful to newbies ..

THANKS IN ADVANCE

Bye
 
Old 05-05-2007, 11:02 AM   #2
indienick
Senior Member
 
Registered: Dec 2005
Location: London, ON, Canada
Distribution: Arch, Ubuntu, Slackware, OpenBSD, FreeBSD
Posts: 1,853

Rep: Reputation: 65
Netbeans is nothing more than a really good Java IDE.

Running Java applications on Fedora is no different than running Java applications on any Linux, UNIX, or Windows box (I'm not sure how Macs handle Java applications, but I'm pretty sure it's quite similar).

When you type "javac ClassFile.java" at a shell prompt, you're just running the Java compiler, and once it's finished running (assuming there were no errors) you'll be left with a new file called - for the sake of this example - ClassFile.class.

To run ClassFile.class, cd into the directory where ClassFile.class resides, and type "java ClassFile".
(Note: There must be a public static void main(String[] args) funtion in that class for it to be runnable.)

To run applications that have been contained in a *.jar file, simply type:
"java -jar JavaProgram.jar"



EDIT: Also, if you've installed FC6 (Fedora Core 6), more than likely the GNU Java compiler (GCJ-compat)got installed, and Netbeans automatically detected that Java system.

If it turns out that this is the case, I heavily recommend uninstalling the GCJ packages (carefully though, they may take out some other programs as it would be considered a dependency), and go to java.sun.com and download the J2SE SDK (with Netbeans) binary installer, and use that instead; as I believe the GCJ system only provides compatibility for Java 1.4.

Last edited by indienick; 05-05-2007 at 11:05 AM.
 
Old 05-19-2007, 12:50 AM   #3
PFudd
LQ Newbie
 
Registered: Mar 2004
Posts: 17

Rep: Reputation: 2
Lightbulb Running Java, outside and inside a browser

Here's a short tutorial on Java.

Testing Java at the command line:

Step 1: Here's a test program for a command-line java program:

Code:
class myfirstjavaprog
{  
        public static void main(String args[])
        {
           System.out.println("Hello World!");
        }
}
One thing that annoys me about Java is that the name of file HAS TO MATCH the class name inside the file. So, name this file "myfirstjavaprog.java".

Step 2: Compile the test program:

Code:
javac myfirstjavaprog.java
This will create "myfirstjavaprog.class", if all is ok. If javac is not found at /usr/bin/javac, Java is not installed right. /usr/bin/javac is a symbolic link to /etc/alternatives/javac, which (in my case) is a symlink to /usr/lib/jvm/java-1.6.0-sun/bin/javac, which came out of an rpm file named jdk-1.6.0-fcs.i586.rpm, from Sun.

Step 3: Run the test program:

Code:
java myfirstjavaprog
Voila, a program that says "Hello world!".

Getting applets running in Firefox

Step 1: Get java running.

Step 2: Make the following symlink:
Code:
cd /usr/lib/mozilla/plugins
ln -s /usr/lib/jvm/java-1.6.0-sun-1.6.0/jre/plugin/i386/ns7/libjavaplugin_oji.so .
Step 3: Restart Firefox
Step 4: Test with http://www.java.com/en/download/help/testvm.xml

If you have the dancing "Duke", congratulations. If you have a blank square, you have what I had yesterday. My accidental solution was to download the non-rpm version of java and install that. I think that was what fixed it, but I was trying a lot of stuff, so I can't be sure.

Getting JNLP pages (aka Java Web Start) to work

Step 1: In firefox, click on a JNLP file. When it asks what to do with it, tell it to run javaws. You'll have to browse for it. Mine is at /usr/java/jdk1.6.0/bin/javaws.

Step 2: There is no step 2. It should just work at this point.

Hope that helps!
 
  


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
Can't get java programs to run in Suse krutten1986 Linux - Newbie 10 09-04-2006 07:16 PM
java programs won't start on desktop kristof_v Linux - Software 4 03-15-2006 03:01 PM
How to run java in Fedora core 3 gjo Fedora 2 10-02-2005 03:18 AM
can't run my java programs crazyzombie Linux - Newbie 1 09-23-2005 01:42 PM
How to run Java programs in a sandbox fpmc Programming 0 07-07-2004 03:57 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:09 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration