File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Linux / UNIX and the fly likes Compile problem in Linux Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Compile problem in Linux" Watch "Compile problem in Linux" New topic
Author

Compile problem in Linux

Ram Keertipati
Greenhorn

Joined: Sep 06, 2002
Posts: 5
I have run the java program successfully in windows using Java 2 SDK 1.4.0.01. But the same program does not compile in Red Hat Linux 7.1 using the same version of Java 2 SDK. I get the following error message at compilation:
myprogram.java:line number: error: cannot find class "JPanel" [JLS 8]
Could someone please help me resolve this?
Thanks very much.
Ram
rkeerti@yahoo.com
Dave Landers
Ranch Hand

Joined: Jul 24, 2002
Posts: 401
That doesn't look like an error I'd expect from Sun's JDK. Make sure you are using the version of java you think. Test with something like this in bash:
type javac
RedHat does come with a version of java (kaffe, I think) in /bin or /usr/bin that does not act like JDK 1.4. You might be using that one accidentally.
Ram Keertipati
Greenhorn

Joined: Sep 06, 2002
Posts: 5
Hi Dave
Your suspicion about /usr/bin is right. javac is available both in /usr/bin and /usr/local/j2sdk1.4.0_01/bin .
Could you please advise me the procedure to use the javac in /usr/local/j2sdk1.4.0_01/bin?
Thank you very much for your help.
Ram
Dave Landers
Ranch Hand

Joined: Jul 24, 2002
Posts: 401
The easiest way is to rearrange your PATH environment variable so that /usr/local/j2sdk1.4.0_01/bin comes first (before /usr/bin). For example:
export PATH=/usr/local/j2sdk1.4.0_01/bin:$PATH
Or you could just always type /usr/local/j2sdk1.4.0_01/bin/javac and /usr/local/j2sdk1.4.0_01/bin/java, etc. This is not so easy.
Ram Keertipati
Greenhorn

Joined: Sep 06, 2002
Posts: 5
Thanks for the advice. I could compile my program. However when I tried to execute it I received the following error message:
Exception in thread "main" java.lang.InternalError: Can't connect to X11 window server using ':0,0' as the value of teh DISPLAY variable
at sun.awt.X11GraphicsEnvironment.initDisplay(Native method)
Below this there were also references to other java classes.
Can I expect your further help on this problem also?
Thanks again for your help.
Ram
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15286
    
    6

Ok, I have some questions.
1. Are you running the X11 serice? Are you currently running a GUI like KDE or Gnome when trying to run your Application?
If not, then GUI components won't work.
2. Are you logged in as ROOT or as a normal user? Sometimes, if I log in as a normal user, the swich to super user mode, and try and run soemthing that requires X11, I get that message. Try running it from whoever you are logged in as, and not using su first.
Let me know..


GenRocket - A Test Data Generation Platform
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Fire up xterm, and do "xhost +".


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Ram Keertipati
Greenhorn

Joined: Sep 06, 2002
Posts: 5
Hi
I am sorry if my problems sound elementary and silly. The reason is that I am new to both Linux and Java.
I logged in as user in KDE.
I have run the program using the Run Command from the Main menu by typing the following in the Run Command window:
java /home/java/j2sdk1.4.0_01/cims/myprogram
I got the same error message as mentioned in my previous posting.
------------------------------------

Fire up xterm, and do "xhost +".
I do not know how to execute the above.
------------------------------------
My aim is run the program which has GUI components of Swing. The program ran perfectly in windows. I want to run the same in Linux as I wish to pursue my further development in Linux environment.
Thank you very much.
Ram
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
The java Swing components are going to use the native windowing system of Linux which is X11.
Now, the window is going to be opened on a display which is usually specified by the DISPLAY environment variable.
Using the bash shell, this would be defined by a command similar to: export DISPLAY=hostname:X11_display_server.screen_number
You have an error mentioning ":0,0" - is that really a comma or a typo? Do an "echo $DISPLAY" to check.
Assuming that it is a typo, and is really ":0.0" it means that you cannot open a window on your local machine.
This sometimes happens when you are running the desired program with a different UID as that user who is running the X11 server. For instance if you logon as a normal user, then do a su to another user (eg. root) and then run a windowing application under that new UID.
If you really need to do the above, you can startup a terminal emulation window (such as xterm, or whatever your window manager provides on your desktop) and run the program xhost with the argument +.

This allows all other processes running under other UIDs to open a window on your display screen. Doing xhost + is a bit drastic because it allows anybody to open windows, so look up the man pages to get a finer control.
BTW, whatever OS you are going to use you will have to learn how it really works behind the curtain provided by the windowing systems. Time spent doing this will make life easier in the long run.
-Barry
[ September 08, 2002: Message edited by: Barry Gaunt ]
Ram Keertipati
Greenhorn

Joined: Sep 06, 2002
Posts: 5
Hi Gregg and Barry
I logged in as root and opened a terminal window. From here I went to my required directory and ran the application. It worked and I got the UI as expected.

Of course there was some other problem but it is something to do with database connection.
The above are the basic things I required to start my work on Linux.
My sincere thanks to both of you and also to Dave.
Ram
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Good to see it's working, but you should really find out why you cannot do it using a nonprivileged user account.
Good luck,
-Barry
 
Consider Paul's rocket mass heater.
 
subject: Compile problem in Linux
 
Similar Threads
rmic stub query
Beginner's classpath problem (I hope...)
@WebService illegal character: \64
Enums (super call)
Compilation of java code at runtime