LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-22-2005, 01:05 AM   #1
biojayc
Member
 
Registered: Mar 2005
Location: Dallas TX
Distribution: Kubuntu 6.10
Posts: 80

Rep: Reputation: 15
Java question


I have a project that I'm doing for school that is several classes big, and has about 10 jpgs that go along with it. Since I recently installed mandrake, I was going to try to get java working. I installed the jsdk, and got it to successfully compile and run a small one class java application. but when I tried to do something multiclass, it doesn't recognize any of the other classes outside the main file. What do I need to do? In windows, I can just compile the file with main, and it'll find all the others if they're in the same dir. What do I need to do here? thanx.
 
Old 03-22-2005, 01:45 AM   #2
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 96
Hi.

Try 'javac *.java' in the directory with your .java files.

Dave
 
Old 03-22-2005, 08:20 AM   #3
ksgill
Senior Member
 
Registered: Apr 2003
Location: Toronto, Canada
Distribution: Ubuntu Jaunty (9.04)
Posts: 1,044

Rep: Reputation: 45
You have to make the methods in other classes static and like the previous post suggested, you have to compile all the classes.
 
Old 03-22-2005, 09:15 AM   #4
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 96
Should that not be public, instead of static?
 
Old 03-22-2005, 09:40 AM   #5
ksgill
Senior Member
 
Registered: Apr 2003
Location: Toronto, Canada
Distribution: Ubuntu Jaunty (9.04)
Posts: 1,044

Rep: Reputation: 45
Public and static are two different things. If you dont make the methods in your classes static and try to reference (use) them from other classes you will get an error. One other way to get over this problem is to create an Object of the class before using its methods.
 
Old 03-22-2005, 09:51 AM   #6
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 96
True, true.

My point was that there's no need to declare everything static. Actually, my point was wrong anyway - there's no need to declare public either, as the default protected is fine for classes in the same package.

Dave
 
Old 03-22-2005, 03:04 PM   #7
biojayc
Member
 
Registered: Mar 2005
Location: Dallas TX
Distribution: Kubuntu 6.10
Posts: 80

Original Poster
Rep: Reputation: 15
I Know how to code java. Like I said, it compiles just fine under windows. It's just in linux, the compiler doesn't find the other classes like it does in windows. A friend of mine mentioned something called ant. anyone know what that is or how I can install it and use it to compile my source?
 
Old 03-22-2005, 03:11 PM   #8
ksgill
Senior Member
 
Registered: Apr 2003
Location: Toronto, Canada
Distribution: Ubuntu Jaunty (9.04)
Posts: 1,044

Rep: Reputation: 45
If your classes are in the same folder there shouldnt be any problems. Could you please tell us if the files are in the same directory and also post the javac output error that you get?

Thanks
 
Old 03-22-2005, 03:42 PM   #9
Magsol
LQ Newbie
 
Registered: Mar 2005
Location: Georgia
Distribution: Ubuntu / Leopard / WinXP
Posts: 23

Rep: Reputation: 15
You might need to configure your classpath, so Java can find the class files in the first place.
 
  


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 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
Question about Java Mega Man X Programming 3 12-27-2003 11:02 AM


All times are GMT -5. The time now is 04:22 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration