Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Annoying Environment Variable  RSS feed

 
Kevin Simonson
Ranch Hand
Posts: 223
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
About two months ago I was having some problem with my code and a co-worker solved the problem by having me set environment variable JAVA_TOOL_OPTIONS to value "-Dfile.encoding=UTF8". Now, ever since I made that change, every time I compile a Java file, and every time I run a Java class, the operating system, before it does anything else, prints out "Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8". For example, I have two simple Java files:

and

and when I compile and run them I get:

C:\K\Java\Misc>j7c HelloWorld.java
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8

C:\K\Java\Misc>j7c Empty.java
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8

C:\K\Java\Misc>j7 HelloWorld
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8
Hello world!

C:\K\Java\Misc>j7 Empty
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8

Does anyone know any way to turn this off so it doesn't keep printing this line out? I want to keep the environment variable set; I just don't want it to keep printing this line out.

Kevin S
 
Jaikiran Pai
Sheriff
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are those j7c and j7 commands? Those look like custom scripts to compile and run Java (perhaps using Java 7). I guess those custom scripts are the ones printing out that output. So you might have to open them up in a text editor and see what they are doing.
 
Kevin Simonson
Ranch Hand
Posts: 223
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jaikiran Pai wrote:What are those j7c and j7 commands? Those look like custom scripts to compile and run Java (perhaps using Java 7). I guess those custom scripts are the ones printing out that output. So you might have to open them up in a text editor and see what they are doing.

They are just aliases to Java 7 javac and java respectively. When I try those two commands I get the same results:

C:\K\Java\Misc>javac HelloWorld.java
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8

C:\K\Java\Misc>javac Empty.java
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8

C:\K\Java\Misc>java HelloWorld
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8
Hello world!

C:\K\Java\Misc>java Empty
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8

C:\K\Java\Misc>
 
Tony Docherty
Bartender
Posts: 3271
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried removing the environment variable and using the -Dfile.encoding=UTF8 switch directly when running javac ie

javac -Dfile.encoding=UTF8 HelloWorld.java
 
Kevin Simonson
Ranch Hand
Posts: 223
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tony Docherty wrote:Have you tried removing the environment variable and using the -Dfile.encoding=UTF8 switch directly when running javac ie

javac -Dfile.encoding=UTF8 HelloWorld.java

I haven't tried that yet. The problem that setting the environment variable solved was with code in IntelliJ. How do I set up IntelliJ so that when I run a program it does it with "javac -Dfile.encoding=UTF8"? I'm hesitant to change the environment variable until I know changing it won't break my IntelliJ builds.

Kevin S
 
Tony Docherty
Bartender
Posts: 3271
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't use IntelliJ so I can't answer that but there almost certainly is way to set the compiler arguments - have you tried looking in the help file?
 
Jaikiran Pai
Sheriff
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kevin Simonson wrote:How do I set up IntelliJ so that when I run a program it does it with "javac -Dfile.encoding=UTF8"? I'm hesitant to change the environment variable until I know changing it won't break my IntelliJ builds.

Kevin S


File -> Settings -> Compiler -> Java Compiler. And then on the right side pane, there's a "Additional command line parameters" where you can add this -Dfile.encoding=UTF8
 
Kevin Simonson
Ranch Hand
Posts: 223
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jaikiran Pai wrote:
Kevin Simonson wrote:How do I set up IntelliJ so that when I run a program it does it with "javac -Dfile.encoding=UTF8"? I'm hesitant to change the environment variable until I know changing it won't break my IntelliJ builds.

File -> Settings -> Compiler -> Java Compiler. And then on the right side pane, there's a "Additional command line parameters" where you can add this -Dfile.encoding=UTF8

Thanks! I modified IntelliJ as you indicated and removed the environment variable, and that solved the problem.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!