aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Exception regarding Linux environment Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Exception regarding Linux environment" Watch "Exception regarding Linux environment" New topic
Author

Exception regarding Linux environment

yekkala krishna
Ranch Hand

Joined: Mar 04, 2007
Posts: 105
Hi,

i am able to run multiSnmpToolClient.jar in windows environment.But when i run same application in linux environment i am getting below exception.
can anybody suggest why i am facing the below exception in linux environment.

[root@apgsdl001 tmp]# java -jar multiSnmpToolClient.jar
Exception in thread "main" java.awt.HeadlessException:
No X11 DISPLAY variable was set, but this program performed an operation which requires it.
at java.awt.GraphicsEnvironment.checkHeadless(Unknown Source)
at java.awt.Window.<init>(Unknown Source)
at java.awt.Frame.<init>(Unknown Source)
at java.awt.Frame.<init>(Unknown Source)
at javax.swing.JFrame.<init>(Unknown Source)
at com.bt.multiSnmpTool.MultiSnmpToolClient.<init>(MultiSnmpToolClient.java:236)
at com.bt.multiSnmpTool.MultiSnmpToolClient.<init>(MultiSnmpToolClient.java:262)
at com.bt.multiSnmpTool.MultiSnmpToolClient.main(MultiSnmpToolClient.java:1927)

Waiting for your reply...
thanks in advacne.

regards,
Rama Krishna.Y
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19696
    
  20

Are you running this in a windowed environment like Gnome or KDE, or from a server? If it is the latter, try adding the following parameter to the JVM itself (so before the class name): -Djava.awt.headless=true. See http://java.sun.com/developer/technicalArticles/J2SE/Desktop/headless/


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
yekkala krishna
Ranch Hand

Joined: Mar 04, 2007
Posts: 105
Hi Rob,

Good to see your reply.
Following is the command which i tried to run my client jar :
[root@apgsdl001 tmp]# java -Djava.awt.headless=true -jar multiSnmpToolClient.jar
Exception in thread "main" java.awt.HeadlessException
at java.awt.GraphicsEnvironment.checkHeadless(Unknown Source)
at java.awt.Window.<init>(Unknown Source)
at java.awt.Frame.<init>(Unknown Source)
at java.awt.Frame.<init>(Unknown Source)
at javax.swing.JFrame.<init>(Unknown Source)
at com.bt.multiSnmpTool.MultiSnmpToolClient.<init>(MultiSnmpToolClient.java:236)
at com.bt.multiSnmpTool.MultiSnmpToolClient.<init>(MultiSnmpToolClient.java:262)
at com.bt.multiSnmpTool.MultiSnmpToolClient.main(MultiSnmpToolClient.java:1927)

Even i make enable before my jar file when i run "-Djava.awt.headless=true" it is showing the above exception.
Can you suggest if i am doing any mistake.

With Regards,
Rama Krishna.y
yekkala krishna
Ranch Hand

Joined: Mar 04, 2007
Posts: 105
Hi Rob,

I am using Solaris OS.


With Regards,
Rama Krishna.Y
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19696
    
  20

Is this a graphical client? And are you running this command without a Solaris windowed environment?
yekkala krishna
Ranch Hand

Joined: Mar 04, 2007
Posts: 105
Hi Rob,

i am using JFrame in our application.(I hope this is a Graphical client)Following is sample syntax:
public class MultiSnmpToolClient extends JFrame
implements Runnable, ActionListener, ComponentListener, ChangeListener
{}


I am connecting to my solaris system with the help of putty.Is it right?or i need to do some configuration settings for this.

Waiting for your reply...

Regards,
Rama Krishna.Y
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19696
    
  20

yekkala krishna wrote:I am connecting to my solaris system with the help of putty.Is it right?

And there is the problem. PuTTy is a text-only client, and it is simply unable to show the user interface. To be able to this you'll need to connect to the Solaris machine's windowing server - if it has any. I remember doing this a few years ago in Linux, where I connected to a remote X server. For Windows there are clients for this as well, although the only one I can think of is Exceed. That one is definitely not free though. You may find something else using Google.

Of course this does require the Solaris machine to a) have a windowing server (like X11 or Xorg), and b) make it accessible for your client machine. For both you will need to contact your system administrator.
Mark E Hansen
Ranch Hand

Joined: Apr 01, 2009
Posts: 643
Rob Prime wrote:
yekkala krishna wrote:I am connecting to my solaris system with the help of putty.Is it right?

And there is the problem. PuTTy is a text-only client, and it is simply unable to show the user interface. To be able to this you'll need to connect to the Solaris machine's windowing server - if it has any. I remember doing this a few years ago in Linux, where I connected to a remote X server. For Windows there are clients for this as well, although the only one I can think of is Exceed. That one is definitely not free though. You may find something else using Google.

Of course this does require the Solaris machine to a) have a windowing server (like X11 or Xorg), and b) make it accessible for your client machine. For both you will need to contact your system administrator.


Actually, it's easier than that. Cygwin includes an X11 Server which you can run on the Windows machine, and it's free.
In your Putty settings, you need to make sure you allow X11 Forwarding (In the Putty settings, this is under Connection -> SSH -> Tunnels). When you connect to the host using SSL, it will set your DISPLAY environment variable to point to a special proxy display (usually something like localhost:10.0).

You don't need to be running any X11 server software on the *nix host at all. When you run the X client application on the host, it uses the proxy display (localhost:10.0) which forwards all the X stuff to your X Server running on the windows machine.

It sounds more complicated that it is.
James Sabre
Ranch Hand

Joined: Sep 07, 2004
Posts: 781

And if you don't want to install Cygwin then there is always
XMing.


Retired horse trader.
 Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.
Mark E Hansen
Ranch Hand

Joined: Apr 01, 2009
Posts: 643
Remember that you don't have to install all of Cygwin. You can install just the minimum, plus the X11 stuff you want.
I had problems when I tried XMing, but I can't remember now what they were. Perhaps it's time to try it again!
James Sabre
Ranch Hand

Joined: Sep 07, 2004
Posts: 781

Mark E Hansen wrote:Remember that you don't have to install all of Cygwin. You can install just the minimum, plus the X11 stuff you want.
I had problems when I tried XMing, but I can't remember now what they were. Perhaps it's time to try it again!


I use it without problems in XP installed on Sun Virtual Box hosted on Ubuntu 9.10 and 10.04.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Exception regarding Linux environment