Colours not enabled with JSCH - java

I'm trying to create a simple Vt100 emulator in Java - which work with JSCH.
Colours are displayed (when I print them with echo for example). But when I open htop, the display is set to monochromatic (and I can't change it). I've looked in HTOP source code, and it comes from a check (ncurses, has_colors): the server think that colours are not enabled on my terminal.
This is of course not a server-side problem (working well with PuTTy).
Thanks.

Related

JDialog fullscreen problem with webstart on Mac OS X Big Sur

The new "Prefer Tabs" system setting in Mac OS X 11 (Big Sur) causes issues with Java applications. If the setting is set to "Always", or to "In full screen" and the application is running in full screen, JDialogs open as tabs and become unresponsive.
There is a way to set the "Prefer Tabs" setting on a per-application basis. For example, running
defaults write net.java.openjdk.cmd AppleWindowTabbingMode manual
in Terminal makes sure that NetBeans (and, seemingly, any application running on openjdk) works correctly.
Our application still supports Webstart on Mac. The above setting does not affect Webstart, so the problem still occurs there. I am not sure where the "net.java.openjdk.cmd" in the above command comes from, and where I can find the equivalent value for Webstart. It doesn't appear to be in Info.plist. Does anyone know what the value should be for Webstart (build 1.8.0_271-b09)? In general, how can I find the appropriate value for a specific application?
[Edit March 25 2021]
In an attempt to minimize burden on our users, my approach is to read the current setting using "defaults read X AppleWindowTabbingMode" from within our software. If it isn't set to manual, the software offers to run "defaults write X AppleWindowTabbingMode manual" and suggests that the user needs to restart the software afterwards.
In an attempt to get the bundle ID programmatically, I tried:
URL u = Main.class.getProtectionDomain().getCodeSource().getLocation().toURI().toURL();
URL canonicalHome = new URL(u.toString() + "jnlp");
appID = "com.oracle.jnlp-" + canonicalHome.hashCode();
but this doesn't seem to get me the right value. As far as I can tell, webstart actually uses something called JavaAppletPlugin which uses a 'java' executable, rather than 'javaws'. Any thoughts on how to programmatically get the right value?
Hope this is still relevant for you.
What you need is the bundle identifier for your app.
For openjdk this is:
<dict>
<key>CFBundleIdentifier</key>
<string>net.java.openjdk.cmd</string>
...
My guess is that a Webstart app is using javaws from the Oracle JVM.
In that case, the bundle identifier is a concatenation (from java source code):
this.bundleIdentifier = "com.oracle.jnlp-" + paramLaunchDesc.getCanonicalHome().hashCode();
You should try to create a shortcut for your app which should contain the bundle info in plist format. Get the identifier.
Then your Terminal command would become:
defaults write com.oracle.jnlp-<something> AppleWindowTabbingMode manual
Update
You might be able to find the identifier using the Java console. Enable it in the Java Control Panel which you can reach via System Preferences.
In the console, look for a log message like:
temp: bundleIdentifier is com.oracle.jnlp--<number>
Obviously it might differ for each installation :-( so you still have to find out exactly how java creates the identifier.

Setting The Environment for System.in

I'm designing a console application for a server running RedHat. The end users should be able to run this app with any terminal of their choosing. (For example; Gnome Terminal, Putty SSH/ Telnet, MS Telnet Client and others).
In most terminal applications there's nothing wrong, however when I launch my program from a MS telnet session I notice my special inputs for System.in and System.console() get totally messed up. A backspace will write ^H to the screen and other keys write gibberish as well.
I've hacked at it enough that I can get it to consistently work, but I'm sure what I'm doing is gross:
if (!System.getenv("TERM").equals("xterm"))
{
System.out.println("\nWARNING: The TERM type is now set to xterm\n");
final String[] cmd = { "/bin/sh", "-c", "export TERM=xterm" };
Runtime.getRuntime().exec(cmd);
}
Would there be an issue here for terminals that don't support xterm? I notice that the Microsoft Telnet client doesn't allow you to set the TERM type to xterm before you begin a session. Once the session is started, however, setting TERM=xterm seems to solve the problem.
How do most console applications go about this issue?
With character terminal applications, there are always two ends in the communication, which must agree on how to interpret the control characters. Usually both sides are capable of using a variety of codings described in termcap/terminfo database.
On the Unix server-side you can define the coding by setting the TERM environmental variable, or by using stty (a default is used otherwise, often a dumb terminal emulation).
On the client side you also have to set the same terminal emulation as on the server side. Windows native telnet has the capability to define the emulation (see e.g. Configure the Telnet Terminal Type), as have other terminal emulators (e.g. Putty), too.
Regarding your design decisions: The above terminal setting are usually only described in user documentation, and not hardcoded in application, to leave more flexibility. After all, you do not know in advance which terminal (only a simple hardware terminal, supporting a single termcap coding, perhaps?) your users are going to use.
(As your question has little to do with Java or system.in, so you could re-consider the tags you use.)
You should look into these two posts, as they are related to what you are doing.
check env variable
set environment variable
As you are running the console on top of the Unix server, redhat in your case, I would also recommend that you look into the Unix command expect, that allows you to read the input in the console application, and performs the action according to the input of the user.
Here are some examples of the command usage.
sample Expect usages

Cannot get Java Applets to work in any browser

We are trying to download something from GE that uses Java to download when logging into the site. This is a windows 7 Professional PC. I have other computers that are able to do this successfully. Here is my order of operations:
Log into the site and select the file I want to download
Click download
It takes me to the page that says it will start in a few seconds but nothing happens. It is supposed to have a box that asks for Java to run.
I have reinstalled Java fresh and still nothing. Tried with multiple user accounts. Added the site to the list of exceptions in the firewalls and Java configuration. I have tried an earlier version of Java. This happens in Mozilla, Chrome and IE. I have made sure that the Java plugin shows up and is enabled. I just cant think of what I am missing. And since we are a contractor GE is not going to help us. Can anyone here think of anything?
Are you sure you have the Java plugin enabled? e.g. in Firefox, go to Settings, Plugins, and change Java Platform SE8 'Next Generation Java Plugin' to 'always activate'?
This sounds similar to the issues I had with Cisco WebVPN, Java-style. Once you have Java installed correctly and set as a plugin for any of the browsers you would like to use, see below.
Before you even start looking at browsers - if you think it is already set up correctly
Look at your Anti-Virus programs or anything else that could prevent it from working. McAfee Host Intrusion Protection is known to cause many Java programs to fail. Kapersky had issues, a while back, with Java on Windows (Java Applets not loading in Windows 8 ).
You must have a 64-bit browser to use 64-bit Java (also mentioned in the Chrome link below).
See below for any specific things that can be modified in the browser.
Chrome 43 is the more complicated browser to set up. They have a dedicated page with instructions.
How do I use Java with the Google Chrome browser?
Firefox 38 will prompt you.
In Internet Explorer 11, it's under Internet Options->Security. I recommend adding the hostname the applet is on as a Trusted Site (Select Trusted Sites and click the Sites button, then add the first part of the url). Click the Custom level button and make sure that Scripting of Java applets is not disabled.
If you still have problems with the applet:
Verify your Java version will work with the applet you are accessing
Verify the plugin is enabled for the browser through the Java Control Panel, which is available in Windows Control Panel, or on Mac/Linux, execute it from the JDK directory ($JAVA_HOME/ControlPanel ).
I ended up fixing the issue. I had to allow their UK site on the list for Java and enable the SSL 2.0 for HTTP in Java config as well

Printing AMCharts graphs on IE8

I'm having a problem printing line graphs from AMCharts.
On my page, the chart is right, but when I try to print it, some spaces are blank.
For example, this image shows how I see the image on my page:
When I try to print it (CTRL + P), some spaces are blank. Look this image:
The problem happens only with IE8 or lower.
In IE9 and IE10 this problem happens when I put in compatibility mode.
In other browsers it works OK.
I need it working in IE8. We have some terminal servers running Windows Server 2003 and can not update the version of IE.
Using another browser is not possible either, because we need multisession and only IE provides this option. We plan to upgrade our servers to a new version of Windows, but it will require some time, and I'm looking for a quick fix.
From what I researched, the amCharts builds the graphics using SVG.
However, in IE8 (or IE9~IE10 using compatibility mode) it uses VML.
Is there any way to make it work with IE8?
Or convert the VML code generated to an Image using Java (language used in the system)?
I researched but dont find anything that can help me.
Is there anything I can do to make it work properly in IE8?

Arduino(RXTX) under Linux? - works in Windows

I'm currently developing a programm with Java to interact with an Arduino module. Now in Windows, it's running pretty well so far (I receive what I expect; I can work with the data), but in Linux (Ubuntu in my case); it's like the opposite. I installed Arduino and rxtx-java packages.
When I tried to use the Arduino program to connect to the Arduino board, I had to set a softlink on the ACM module to some serial or USB module. For example,
ln -s /dev/ttyACM0 /dev/ttyS99
Otherwise it won't even show up in the list in the Arduino program. So what I did then was starting the serial monitor tool (Ctrl + Shift + M) and sent it my start sequence waiting for an answer. It worked without a problem there (it was binary data so I couldn't verify if it was correct, but I got an answer at least).
The next thing I did was trying to do the same with my program, so the Arduino was connected to the PC, the softlink was set correctly, the device listed along with two normal COM-ports I have in my PC in my program, and I tried to connect, but it didn't work.
No error, no nothing, simply no answer of the board. After I waited a couple of minutes, it still didn't do anything, so I disconnected it from the PC, and then I got an array of zero-bytes as the answer.
What could cause this kind of problems and how would I fix it?
Thanks for your help
Volker
PS: the program is a jar file with all libraries/dependencies included
EDIT:
Hardware is an Arduino UNO Board Model R3,and on windows i'm using Arduino 1.0 to program it
Your symlink to /dev/ttyACM0 is double dubious:
Disconnecting+reconnecting or powering off+on might change the number of the dev.
ttyACM usually refers to modems, not to plain USB-serial converters like that used by Arduino (at least those with the FT232 chip). I would expect something like ttyUSB0. For those you also would not need a symlink.
If you installed from the Ubuntu packages you're bound to have problems. I tried this first myself only to find that there are serious issues. I would recommend downloading the most recent version of the IDE arduino-1.0-src.tar.gz.
You'll notice it's the source, I think you'll like it better that way. Or you can get the repository from Git, you'll find that information plus how to build the IDE in Building Arduino, Steps for First Time Setup. Besides the fact that the Ubuntu distribution version is buggy, it's also like old, big time.

Categories

Resources