Colored output in netbeans console with ansicodes - netbeans

I am trying to get a colored output in my Netbeans output window.
Ansi-Output in Linux and Windows console works perfectly fine. However not in the IDE.
Is there a way to make this work in Netbeans' output window?
According to this
https://netbeans.org/bugzilla/show_bug.cgi?id=214546
it should work, but it doesn't in my current Netbeans 8.0.1 installation (neither Linux nor Windows).
Any hints on how to do that?

I am using Netbeans 8.0.1 myself, on Windows 7. I just tried ANSI escape code, and it works. Example:
String greenBold = "\033[32;1m";
String reset = "\033[0m";
System.out.println("before" + greenBold + " green " + reset + "after");

There seems to be a problem when using Maven 3.5.x.
See:
https://netbeans.org/bugzilla/show_bug.cgi?id=270593
https://github.com/fusesource/jansi/issues/87
I tried NB 8.2 with the old Maven 3.3.9 first and it worked fine out of the box. The whole output remained as it had been but my application's own logs were colored as expected.
With Maven 3.5.2 and 3.5.4 the colors didn't work at all. So I had to set MAVEN_OPTS environment variable to "-Djansi.passthrough=true" (as suggested in the first link) and restart NetBeans. The problem is that now the whole output is colored differently and error stack traces don't contain links to code any more. So I'm switching back.
BTW. When using log4j2's %highlight{}, I also had to set disableAnsi="false" to get the desired effect:
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} %highlight{%-5level} [%t] %location --- %msg%n%throwable" disableAnsi="false" />
</Console>

I'm using NetBeans 12.3 and I had same problem. Problem is with bundled Maven (version 3.6.3).
When I changed to Maven which I installed on my system it works. Note that version of Maven installed on my system is the same as the bundled one - 3.6.3.
I have changed location of Maven in settings:

#YoungFrog solution was the best for me.
I spent all day to get NetBeans 14 working with hyperlinks and ANSI colors simultaneosly.
chmod -r /path/to/netbeans-14/netbeans/java/maven/lib/jansi*
did the job.
Actually, for me it was bad to change the default maven installation folder. In order to have all the output correctly working (hyperlinks in stack trace, ANSI colors in output, no NETBEANS-EXEC lines) I suggest you to use the one bundled with the specific NetBeans version you have installed.

Related

Cannot disable CompactStrings Java 9 using Netbeans

I am trying to disable the CompactStrings feature of Java 9 using the VM option: -XX:-CompactStrings, but it does not work.
When I tried to debug my application, the COMPACT_STRINGS variable in String class is always true (with or without the VM option)
I have the latest version of Java 9: jdk-9+181
And the Netbeans IDE Build 201709070001
I tried various options to set the VM option and none of them works.
What I tried is:
setting the VM option in app.conf, setting it in project.properties, running netbeans by ./netbeans -XX:-CompactStrings, setting the JVM option in Project->Properties->Run->VM Options
Is this a bug in Netbeans? Or am I doing something wrong?
I tried to reproduce your problem using a trivial "Hello World" Java application. However, toggling the CompactStrings feature in the project properties settings worked fine for me, and caused COMPACT_STRINGS to be set appropriately, so this is not a bug in NetBeans.
Although I am using the same version of Java (181) as you, I have a more recent Dev Build of NetBeans (Build 201709220002), and there are several discrepancies between my project properties screen and yours. For example, mine shows the Runtime Platform field but yours does not:
Something else to check is that you really do have the environment you expect. I find it easy to mess things up when multiple versions of Java and Netbeans are installed.
This is what I see when I do Help -> About:
If your environment looks fine then I can only suggest that you download the latest DEV Build of NetBeans and try again.

Bad screen redrawing in Oracle SQL Developer after statment with error [duplicate]

I have a problem with Oracle SQL Developer. When I use it on a Windows Server 2003 machine, it works fine. When I use it on my Windows 7 desktop, I get a lot of redraw problems in the query results grid when I scroll either horizontally or vertically, like so:
Edit: ImageShack was the original image host for my screenshot, and it's no longer a valid url. Since my problem is fixed now, I can't repro this. The gist is that the client area of the result grids was repainted as gibberish during scrolling.
This makes it tricky to assess the results of your queries. Clicking on the header and on individual cells causes it to then redraw properly, but it's goofy to not be able to just scroll normally. Is there any way to fix this? I am using the current version of SQL Developer 1.5.5 with the included JVM.
I couldn't even see the dropdown list when I clicked Tools. Here's what I did.
Click Tools
Try to locate Preferences by moving your mouse downwards starting from the Tools button.
When in Preferences, do the same in step 2 for the left side of the panel and try to locate Environment.
When in 'Environment', try to locate 'Look and Feel'. You won't be able to see the caption but it has these values: Windows | Oracle. You'll know you found it when you see a dropdown with an actual value of Oracle.
Change it to Windows.
That solved my problem.
To hell with these kinds of stupid problems.
You need to turn off DirectDraw -- see http://tiredblogger.wordpress.com/2009/05/29/configuring-oracle-sql-developer-for-windows-7/, specifically the bit where they add the following to sqldeveloper.conf:
AddVMOption -Dsun.java2d.noddraw=true
I finally solved the problem:
Go to \sqldeveloper\bin\sqldeveloper.conf and add this line:
AddVMOption -Duser.language=en
The problem was de user language (in spanish do not works)
I finally solved the problem after many tries in windows 10. Oracle should fix this without tricks...
What I did:
Download lastest sqldeveloper 4.1.5 with JDK bundled.
Run sqldeveloper and import settings from previous install.
Close sqldeveloper, and go to USER\AppData\Roaming\sqldeveloper erasing config folders of older versions.
Modify file \sqldeveloper\sqldeveloper\bin
Change this option value to true
AddVMOption -Dsun.java2d.ddoffscreen=true
Comment line:
#AddVMOption -Dsun.locale.formatasdefault=true
Add this options before IncludeConfFile sentence at then end:
AddVMOption -Dsun.awt.keepWorkingSetOnMinimize=true
AddVMOption -Dsun.java2d.noddraw=true
And finally always start sqldeveloper with sqldeveloper\sqldeveloper\binsqldeveloper64W.exe
And change sqldeveloper theme to "windows style".
This problem still reproduces in 2015, I'm using W7, jdk version 1.8.0_40-b25 and sqldeveloper version Version 4.1.0.18.
I had the same problem and nothing seems to help, not even William Rose's answer, until, in my desperation, I put the AddVMOption from his answer in the last line of my sqldeveloper.conf file and Voila! It worked. It seems that somehow the option is shadowed if you put it at the begging.
Just wanting to add this bit of information, but I can't comment yet due to lack of reputation.
i had the same problem with vista and win 7.
just downloaded the latest sql developer 1.5.5 version WITHOUT jdk included
exported my connections from the previously installed sql developer and
deleted my installed version!
then downloaded the JDK 1.6 update 16 from sun and installed it: http://java.sun.com/javase/downloads/index.jsp (32bit version! even if you have win x64. sql developer doesn't accept JDK x64!)
then i unzipped the sql developer 1.5.5 i downloaded (without the jdk)
on first start sql developer asks you for the path to java jdk: given it the path that i installed the jdk 32bit from above and it now runs fine!
even without switching from aero to basic windows design and without redrawing-problems.
hope this helps you too...
Just install old version Oracle SQL Developer 3.2.2 (3.2.20.09.87) and jdk-6u35-windows-x64.
That's how I solved the problem.
I made this step after solved
Add or replace the attribute of the following config file.
..\sqldeveloper\bin\sqldeveloper.conf
AddVMOption -Dsun.java2d.noddraw=true
Turkish developer can see this site
Remove or comment out the line below in sqldeveloper.conf:
# AddVMOption -Dsun.locale.formatasdefault=true

PyDev code analysis not working properly

I'm having a problem with PyDev and Eclipse. This first happened with some old EasyEclipse version I had. I thought it was just because the EasyEclipse install was old, but it's now also happening with Eclipse 4.2.1 and PyDev 2.7.1. I'm running Python 2.7.3.
The problem is the type-time code analysis seems to be faulty or running the wrong Python version. It thinks this line has a syntax error:
x = 1 if some_boolean else 2
It's expecting a newline instead of the if-keyword. When running the module it works as expected.
This is very annoying as this one error seems to mess up further code analysis that would actually be useful. I'm not sure if it has something to do with the problem, but this site instructed me to try running the interpreterInfo.py, so here is the XML dump it generated.
Any thoughts?
Go to Project -> Properties, click on PyDev - Interpreter/Grammar, and then choose 2.7 in the "Grammar Version" drop-down.

Could not initialize class net.sf.jasperreports.engine.util.JRStyledTextParser

I'm trying to display my reports on the browser , but I keep getting this error:
the strange thing about this, is that it only happens when I attempt to generate the reports from the version installed on the server, but not when I do it locally from my pc
Have you any idea why this is happening ?
For those still running into this issue: on Ubuntu Server 12.04 with headless OpenJDK JRE, it was simply solved by
apt-get install ttf-dejavu-extra
This seems like a Headless mode issue. You need to set the java.awt.headless property to true. That can be done using:
static {
System.setProperty("java.awt.headless", "true");
}
Or, by setting the headless property in your tomcat startup command as -Djava.awt.headless=true
Also, you can read more on why this is necessary, you can read about the Headless mode here
For me the issue was regarding a bug in AdoptOpenJDK: https://github.com/AdoptOpenJDK/openjdk-build/issues/682
I fixed the issue by installing ttf-dejavu manually in my dockerfile
FROM adoptopenjdk/openjdk8:alpine-jre
# Workaround for wrong font configuration in adoptopenjdk
# https://github.com/AdoptOpenJDK/openjdk-build/issues/682
RUN apk update && apk upgrade \
&& apk add --no-cache ttf-dejavu \
# Install windows fonts as well. Not required..
&& apk add --no-cache msttcorefonts-installer \
&& update-ms-fonts && fc-cache -f
AND by running the application with the flag -Djava.awt.headless=true
This is a missing jars in the class path issue.
I had this issue and found that with by adding the missing jars to the class path it resolved the issue.
From the below article
java.dzone.com article
I found that the minimal jars necessary are...Now The versions numbers have changed but with these libraries only I managed to get it working.
jasperreports-2.0.4.jar
commons-digester-1.7.jar
commons-collections-2.1.jar (commons-collections.jar)
commons-logging-1.0.2.jar
commons-beanutils.jar
iText-2.0.7.jar (used infor PDF exporting)
This can as well be caused by missing/inaccessible Java 'temp' directory. In Font.java, temp files are being created:
Files.createTempFile("+~JF", ".tmp").toFile();
On one system, the 'temp' dir was missing under Tomcat folder but Java was configured to use it:
-Djava.io.tmpdir=C:\Program Files (x86)\Apache Software Foundation\Tomcat 7.0\temp
BTW. first time around, after restarting Tomcat, the service was actually throwing an IOException, but then JasperReports cached something and on subsequent calls the stack trace was exactly as reported here.
I got this error while deploying springboot app (including jasper reporting) in docker container.The problem was with openjdk:8-jdk-alpine which I used for building docker container environment. That has a bug in fonts support. Therefore I switched to openjdk:8-jre (or OpenJDK 7 versions will also help) and it worked for me. I spent days to fix this bug.
To resolve the issue, do the following:
Switched from Open JDK to Sun JDK
Installed MS Core Fonts
Packaged JasperReport font library jar with the application
this may be problems with memory, reboot the server.
I know I'm late but couldn't resist answering this one to help out a lot of guys in trouble. After a lot of trial and error, figured out that xml-apis jar is excluded in catalina.properties of tomcat. Remove it from there and it should work. Didn't notice any side effects till now, works great.
Also, make sure the fonts are installed and check gradle/pom for merge strategy if any exclusions are made on xml-apis jar.
BTW, this problem started coming for us after upgrading to jdk11 and moving from tomcat 8 to 9.
I searched several hours for the same issue, and my solution is none of the others mentioned.
Due to a bad update of my jasper reports version I had multiple versions of the jasperreports jar file on my classpath. Make sure you only have a single jasperreports jar file...
A little late, but here is why we had this problem... We recently started developing with IntelliJ instead of Eclipse. We simply forgot to run IntelliJ as administrator... We had done this with Eclipse for a long time already, but simply didn't think about it with IntelliJ.
In the end, I guess the fonts weren't found or a folder was not found since there were insufficient rights to read/write on the c drive.
Got the same error - apparently JRStyledTextParser is using dependency from xml-apis
By adding xml-apis I got it fixed
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>1.4.01</version>
</dependency>
In my case i was using Arial fonts for this i have configured arial fonts in irfonts.xml
which was like below
<fontFamily name="Arial"><normal><![CDATA[fonts/arial.ttf]]>
</normal><bold><![CDATA[fonts/arialbd.ttf]]></bold> <italic><![CDATA[fonts/ariali.ttf]]></italic><boldItalic><![CDATA[fonts/arialbi.ttf]]></boldItalic><pdfEmbedded><![CDATA[true]]></pdfEmbedded></fontFamily>
but it should be like :
<fontFamily name="Arial"><normal><![CDATA[fonts/arial.ttf]]></normal><bold><![CDATA[fonts/arialbd.ttf]]></bold><italic><![CDATA[fonts/ariali.ttf]]></italic><boldItalic><![CDATA[fonts/arialbi.ttf]]></boldItalic><pdfEmbedded><![CDATA[true]]></pdfEmbedded></fontFamily>
so their was a space before the end tag of each tag in above configuration file.i fixed it by removing space between them.
This might help ,I had the same error and every other solution didn't work.
I fixed it by updating to java8.
In our case it helped to delete the temp server (thus making sure there are no jar duplicities) and restart server.
Hint: try this in case if the error starts occurring after a new release (but worked before and nothing relevant changed in the release)
I've faced the same issue on my development machine. Basically it was happened due to problem in application server (Apache tomcat)
Basically I've accidentally deleted the "temp" folder in server root. So jasper cant compile the report and proceed with the report generation.
You can try make a downgrade to jdk7, it's works to me.
sorry my english!
In my case problem was with the jdk8 which I was using to build docker image, but after some search I switched to jre. That fixed my bug. I think you can try any image rather than using jdk8.
There are 2 steps to solve this problem.
-Djaav.awt.headless=true in startup script or vm options
Install the fonts
yum install fontconfig
Then you can verify
rpm -qa | grep font
fontpackages-filesystem-1.44-8.el7.noarch
dejavu-fonts-common-2.33-6.el7.noarch
fontconfig-2.13.0-4.3.el7.x86_64
dejavu-sans-fonts-2.33-6.el7.noarch
This is on CentOS 7.
We had been using Google Noto fonts and thought that we do not need any font installation but was wrong.
For me this error was because I had upgraded JasperSoft Studio and thereafter new or edited reports were compiled in a newer JasperReports version and were therefore unreadable by the server. There is a compile compatibility mode in Studio, but I couldn't get it to work, and the version I was running on the server (6.6.0) wasn't listed as an option in the list of compatibility versions (and using other "close" versions didn't work either).
I ended up installing a legacy Studio version 6.6.0, and recompiled my reports in it. When I deployed the new .jasper files to the server they worked right away and all is well again.
Using Payara (4 in my case) already has -Djava.awt.headless=true, We are using Jasper 6.6.0 but downgraded to 6.4.0 (for another dependency)
we had the same problem when did a fresh install of payara4 with oracle JDK 8u281, downgrading to 8u181 or 8u171 solved it
Upgrade your jasperreports-dependency.
I got a similar stacktrace, when using this outdated version of jasperreports:
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>6.1.0</version>
</dependency>
This fixed my issues:
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>6.17.0</version>
</dependency>
For us the problem was that we had to use the standard Openjdk version not the alpine one. I assure you that all the other fixes don't work.

How does one install 'rj' in StatET plugin for Eclipse?

I have started to try to use StatET and Texlipse with a view to producing SWEAVE reports. When starting the R console in the StatET plug-in for Eclipse (OS X 10.6.4), I get the message:
[INFO] The R package 'rj' is not available, R-StatET tools cannot be initialized.
Information on http://www.walware.de/goto/statet states:
"The package only works in the default R Console (RJ) in StatET. Therefore you have to install and update it using the command line":
R CMD INSTALL --no-test-load rj_*.tar.gz
What does this mean exactly?
In Eclipse under "Install new Software" and the site
WalWare - http://download.walware.de/eclipse-3.6
it states that
RJ Core Library 0.5.0.b201008271600sw
is already installed.
Any helpful guidance gratefully received.
[rant] I also lack the reputation to put my response where it belongs. And there's no button there indicating this. Just a big screen full of nowhere desired to click upon. Negative discoverability sucks. It sucks in Eclipse and it sucks here, too. [/rant]
I'm finding rj frustrating under Ubuntu. On my system, with each major Ubuntu upgrade with a new version of R, I have to go through this procedure over again.
One time I tried to use a tilde (~) character in a path name within some Eclipse configuration field. This failed silently.
My current configuration is as follows. In my ~/.Renviron file:
R_LIBS_USER=~/etc/R/amd64/2.11
Once rJava works, there is an rJava directory here. Just so I don't drive myself insane, in ~/etc/R/README I put a note that my current R configuration is controlled by ~/.Renviron
Somehow at one point I ended up with permission problems where
R CMD javareconf
was failing. Once in frustration I foolishly ran this under sudo to work around this problem, and ended up with permission problems on the generated files. Stupid! The correct fix was to make all the files in /etc/R world readable. Maybe javareconf is only important if you mess with your default Java. Previously, I was running the Sun's JRE. Since 10.10 I'm running icedtea6 and it seems to be working OK. One time it was just the thing to make my configuration work again.
Once I have the right Java binding, from command line R:
install.packages("rJava")
I've had file permission problems running this in the past. I think it was fixed by making all files in /etc/R world readable.
The following is a useful diagnostic to see if this worked, from within any R console:
> system.file("jri",package="rJava")
[1] "/home/allan/etc/R/amd64/2.11/rJava/jri"
If it doesn't look right under Eclipse, there is also some startup debugging available, though it took forever before I noticed this in the docs at StatET.
I created an R Console run configuration for R 2.11 debug In the JRE tab add -Dde.walware.rj.verbose=true. In the Common tab, click Allocate additional Error Log Consoles.
The main configuration options are as follows. Main tab, Launch Type: RJ. R_Config tab, you need to select a Configured R Installation, or create/edit one if you don't have one that works. Mine is Name=R, Location=/usr/lib64/R In the Environment tab I have R_LIBS_USER=/home/USER/etc/R/amd64/2.11 according to how I set things up above. Do not use the tilde (~) character here!
If you end up mucking about with this problem as much as I did, you end up killing a lot of dead consoles. In the Main tab I added the program option --no-save. I don't think this does anything, since I can't end my console by pressing CTRL-D. In the R_Console tab, I added the following R snippet:
q <- function(save = "no", status = 0, runLast = TRUE){
.Internal(quit(save, status, runLast))
#<environment: namespace:base>
}
This gets rid of the annoying "save workspace" prompt when killing an R console with the red square (is that symbolic?) My current workspace also includes a C project, so my R console constantly comes up underneath a blank C-Build console. Annoying as all hell! Haven't solved that yet, but I did discover that from within a StatET code windows the keybinding CTRL-R C pulls the R console to the top.
With my R 2.11 debug configuration I get an extra console titled /usr/lib/jvm/java-6-openjdk/bin/java. You'll have to spelunk the console drop-down to find it. The following is a pertinent snippet of a successful initialization:
CONFIG: JR library path:
/home/allan/etc/R/amd64/2.11
/usr/local/lib64/R/site-library
/usr/lib64/R/library
10-Dec-2010 7:56:47 AM org.rosuda.rj.JRClassLoader addClassPath
FINE: Added '/home/allan/etc/R/amd64/2.11/rJava/java' to classpath of URL loader
A lot more spoo, then finally:
10-Dec-2010 7:56:48 AM de.walware.rj.server.jriImpl.RosudaJRIServer start
INFO: R engine started successfully. New Client-State: 'Connected'.
Looks good, right? But lo and behold in the R console:
[INFO] The R package 'rj' is not available, R-StatET tools cannot be initialized.
Ignore the lying bastard! Turns out my rj is working just fine. No idea why this failure message persists.
Every time around the block with this problem some new amazing piece of gravel ends up in my sneaker.
I don't know whether I've covered everything, but I've written enough for now. Maybe if there are comments I'll come back and fill in the blanks.
Note: found an Eclipse plugin for console switching by keyboard here: Eclipse: Keyboard shortcut for switching between consoles?
It looks like you need to install the RJ library which can be downloaded from the StatET site here: http://download.walware.de/rj/rj_0.5.0-5.tar.gz (more recent versions of RJ can be found at http://www.walware.de/it/downloads/rj.mframe)
If you save that file on your desktop, you can then load it into R with the command they provided R CMD INSTALL --no-test-load rj_*.tar.gz after navigating to your desktop or wherever you saved the library file. Alternatively, you MAY be able to use the GUI interface and select Install packages from local ZIP files under Packages in R, though I haven't used R on a Mac so the layout may be slightly different.
After installing rj with in the R console using
install.packages(c("rj", "rj.gd"), repos="http://download.walware.de/rj-1.1")
(See http://www.walware.de/?page=/it/statet/troubleshooting.mframe for the correct rj version),
do not forget to update the R_LIBS variable in Eclipse (Windows -> Preferences -> StatET -> Run/Debug -> R Environments -> Edit). To find out the value just type in the R console:
packageDescription("rj").
In my windows 8 installation this returns C:/Users/Fibonacci.PYTHAGORAS/Documents/R/win-library/3.0/rj/Meta/package.rds. The value of R_LIBS I set to
C:/Users/Fibonacci.PYTHAGORAS/Documents/R/win-library/3.0
which is the path where all libraries are installed.
As stated in http://www.walware.de/?page=/it/statet/troubleshooting.mframe newer versions (Versions > 0.5.5) do not need the R CMD INSTALL etc... command.
Here the quite similar I had and the solution I found.
I originally installed Statet using the Eclipse built-in tool "Install new software ...."
I seems it downloaded Statet + rj and that the installation process went well.
After this first installation, I tried to install both packages again. Eclipse refused reading that they already are installed. And, both packages/programs were actually listed in the window of Eclipse.
But, the R console still refused to launch, the dialog box reading that I had to check whether rj was available and that the file paths were correct. Another strange thing was that window explorer had been unable to locate rj on my disk.
???
To solve my whole problem, I simply downloaded rj from http://www.walware.de/ and installed this package via the r console and using the basic install.packages() command.
It now works perfectly .
But, I still don't understand everything ..... :-)
I'd make a comment but I lack the necessary reputation. For Windows, the procedure is the same. There's no zip file. Use the tar.gz. Worked for me. The command, working from the same folder as the downloaded file:
$ G:\R-2.12.0\bin\i386\R.exe CMD INSTALL --no-test-load rj_*.tar.gz
The project is now hosted on GitLab, see
https://gitlab.com/walware/de.walware.rj-server.gr/-/wikis/Installation.
To install:
install.packages(c("rj", "rj.gd"), repos="https://download.walware.de/rj-4.0")
Note that binary packages are available for Windows.
As explained in this message from Stephan Wahlbrink on 2022-02-03 announcing StatET 4.5 release, this version works with R 3.6 to 4.1, and RJ-4.0.
For current information on StatET, check the home page and especially the news.