LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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 12-26-2003, 09:44 PM   #1
Mega Man X
LQ Guru
 
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Rep: Reputation: 65
Question Question about Java


Hello there!!!

I'm trying to compile and run a program in Java, but I cannot get the handle of it. In windows, to compile Java code, I call, for example, javac Prog.java and it compiles. To test and run this application, I simple type java Prog.

I cannot get it to work under Linux. I've tried to compile it with:

gcj -c Prog.java

I've also tried -S, -E and a hole lot more. It does, compiles the program perfectly, but I cannot run the program by simply typing java Prog, because the Prog.class was not created as javac does.
however, I've tried to run a compiled program (in windows). In this directory I have Prog.java and Prog.class. Typing:

java Prog

runs the program fine. JSDK is installed fine, since when I type java it returns the version info. I've J2SDK1.4 installed, and the gcj package as well. I'm running Slackware 9.0, with defaults gcc and gcj if that's of any help.

Any ideas how to compile and run a program under Linux, or at least, create a .class for me to run my projects?.

Thanks in advance for any help


P.S: I cannot find my javac under Linux :S
 
Old 12-26-2003, 09:49 PM   #2
Mega Man X
LQ Guru
 
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Original Poster
Rep: Reputation: 65
lol, so simple that it made me feel stupid...

gcj -C Prog.java

will do it. I still wonder where my javac is anyway
 
Old 12-27-2003, 09:46 AM   #3
eric.r.turner
Member
 
Registered: Aug 2003
Location: Planet Earth
Distribution: Linux Mint
Posts: 216

Rep: Reputation: 31
Quote:
Originally posted by Megaman X
I still wonder where my javac is anyway
You can download and install the J2SE SDK from Sun's web site if you want javac, etc.
 
Old 12-27-2003, 11:02 AM   #4
Mega Man X
LQ Guru
 
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Original Poster
Rep: Reputation: 65
Thanks eric.r.turner . I've installed the j2sdk from sun's homepage, but I think something went wrong. In Windows, the directory to javac is <where you installed java like this java\bin\javac). Or it either has a different path for Linux or something went bad during the install process. I will try to reinstall it later again if needed. So far, gcj is doing a great job
 
  


Reply



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 question Jongi SUSE / openSUSE 2 09-19-2005 01:07 PM
Java Question k1ll3r_x Programming 2 08-20-2005 08:10 PM
java question zaicheke Programming 5 02-15-2005 12:40 PM
Java Question k1ll3r_x Programming 3 11-13-2004 04:27 AM
java question TommyD Linux - Newbie 4 07-19-2003 04:29 PM

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

All times are GMT -5. The time now is 09:58 PM.

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