如何在Netbeans中使用-g选项进行编译?

Mal*_*ker 4 java netbeans compilation

在调试时,我收到一条关于异常的警告消息'variable info not available - compiled without -g'- 如何设置在netbeans中使用-g进行编译?

谢谢

Tho*_*sen 7

据我所知,您自己的代码是使用调试信息编译的.但是,Java运行时库不是.

请仔细检查您看到此消息的位置是否在您自己的代码中,而不是运行时库中.


小智 5

在我的Nb 7.4中,
项目属性上有一个"生成Debuging info"标志- > Build - > compile;

但如果你像我一样使用maven,你也必须检查pom.xml

让我举一个例子:
您可以生成一个生产配置文件,在该配置文件中,您可以将maven编译器插件的调试设置为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>
 ...
Run Code Online (Sandbox Code Playgroud)


如果您的pom.xml上的类似设置没有显示,那么请参阅false设置.