• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Annoying Environment Variable

 
Ranch Hand
Posts: 249
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 249
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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>
 
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 249
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 249
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
To get a wish, you need a genie. To get a genie, you need a lamp. To get a lamp, you need a tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic