How do I compile with -g option in Netbeans?

2019-02-18 07:49发布

When debugging I get an warning message on exception saying 'variable info not available - compiled without -g' - how do I set to compile with -g in netbeans?

thanks

2条回答
闹够了就滚
2楼-- · 2019-02-18 08:27

In my Nb 7.4 there is a "generate Debuging info" flag on
project propertyes -> Build -> compile ;

but if you, like me, are using maven, you have to check in pom.xml too

let me show an example:
you can ave a production profile and in that profile you can have the maven compiler plugin with debug setting to false

        <profile>
        <id>production</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>2.5.1</version>
                    <configuration>
                        <encoding>UTF-8</encoding>
                        <source>1.6</source>
                        <target>1.6</target>
                        <showWarnings>true</showWarnings>
                        <debug>false</debug>
                        <optimize>true</optimize>
                    </configuration>
                </plugin>
            </plugins>
        </build>
 ...

see the false setting
if you have a similar setting on your pom.xml local variable on debug are not show.

查看更多
贼婆χ
3楼-- · 2019-02-18 08:43

As far as I know your own code is compiled with debug information. The Java runtime library, however, isn't.

Please double check that the location you see this message, is in your own code and not the runtime library.

查看更多
登录 后发表回答