Text encoding not working properly on execution - java

I've been working for some time on my current project with Java (1.8.0_31) in IntelliJ IDEA (15.0.1 for Windows x64), where I use some text lines with special characters (e.g. "ó"). It has been working so far with no issue, but today it won't.
To put it short, I have a code line like this:
System.out.println("ó");
which has been outputting this (expected):
ó
Today, the output with the same source code is (unexpected):
ó
Code files are encoded in UTF-8 and the editor is setup accordingly. AFAIK, I've changed nothing.
I've created a brand new project to test this and it worked properly, so it may be something related specifically with my project.
Any idea about how to solve this?

Related

Running Java files on VS Code flashes a CMD and shows no output

I'm new to Java and already installed the extensions that VS Code suggests, however, when I try to run my code (it's just a "Hello World") a CMD appears for less than a second and then no output is shown. I also tried an online compiler and the code ran just fine. I reinstalled VS Code and JDK but that didn't solve the problem. Please let me know if you need more information.
Thanks in advance!
Before you change the relevant settings, the result of running the code in VS Code should be output in the terminal.
Please use Ctrl+Shift+P to open the command palette, then search for and select Preferences: Open Settings(JSOn). See what settings have been modified in the file.
Also, follow this documentation to start writing Java code with VS Code.

"out" and "in" characters broken in Eclipse

Hey guys,
Recently I installed Eclipse (Neon 4.6.3) on my Ubuntu (16.04) GNOME OS and ran into some problems, like special characters breaking on originally Windows 8 workspaces and GTK3 Gnome interface problems (had to force it to initiate on GTK2). But still got a minimal and quite annoying bug that I couldn't find any kind of fix nor workarounds, didn't find any infos about that on the web either. The "out" and "in" from System seems to be broken somehow, they appear as characters that doesn't exists when I put it after "System.", right as it gets formatted by Eclipse. Does anyone have any idea of where this is coming from?
Image 1
Image 2
With default settings Eclipse will render static methods and fields with italic characters. It might be a font problem on your system. You can change the configuration under Preferences > Java > Editor > Syntax Coloring. Turn off the syntax highlighting for statics there.

Gradle build won't process Hindi unicode characters

I have added some Hindi characters in Unicode to a Java program. Eclipse has no trouble with it, and can run this code, but Gradle keeps crashing - apparently this is due to javac making assumptions about character sets.
I believe I could handle this by converting my whole source directory to Unicode, and specifying encoding as "unicode" in the build.gradle file.
a) is there an official converter, and b) if so, how can I drive it from the build.gradle file?
The program in question is at https://github.com/jpaulm/drawfbp/blob/master/src/main/java/com/jpaulmorrison/graphics/MyFontChooser.java - line 272. Strangely, Gradle has no trouble with the Chinese characters at line 286, so why does only Hindi have problems? Help would be much appreciated!
This is embarrassing! I had one segment in Russian and another in Hindi (Devanagari), the former in ASCII, the latter in Unicode. I assumed my problem was with the Hindi, but it was actually with the Russian! When I converted the Russian to Unicode, everything worked fine (both Eclipse and Gradle)! Abject apologies! I guess we can close this one!

Why do I see a red cross over index.jsp?

I have set the jdk compliance level to 1.7 and the JRE version I am using is also set to 1.7.
But I am getting a red cross on index.jsp. What could be the reason for this ?
Though I can see the file running in the browser, eclipse's console doesn't show any error.
First make sure there really are no errors: Window -> Show View -> Other... -> Markers.
If there are none, sometimes Eclipse gets stuck thinking there are errors when there aren't. Close all editors, clean the project, close then reopen it in the project explorer (right-click on it), and see if the error clears.
I've also noticed that Eclipse has weird issues parsing JSP; sometimes it's confused and you just have to ignore it, but you could try opening the JSP file, selecting all, cutting, then pasting to force a recheck (or sometimes cut -> clean build -> paste).
I don't know why it does this, and I've been reading / filing bug reports for literally years, but it really seems to choke on JSP (something about the mix of HTML, Java, and JSP tags doesn't sit right with its parser).
Eclipse marks with this sign any file containing syntax errors (not compiling). If you don't have any syntax errors, then you should try cleaning up all your projects, as sometimes it may look inside old metadata files to determine whether there are errors in a given file.

Eclipse code not indent properly in git

I write code in eclipse and indent it properly there. It also looks fine in Eclipse. But when I push that code in github(I am using bitbucket) and then go to git. I see that in github(I am using bitbucket) the indentation is totally messed up.
Any solution for this.
You probably have a mixture of tabs and spaces and the tab stop settings (number of spaces that equals one tab) in git (did you mean GitHub) are different than what you have set in Eclipse.
You can use http://git-scm.com/docs/gitattributes to tweak these settings.
.java text diff=java trailing-space space-before-tab -indent-with-non-tab

Categories