How to run build using graphics drivers by using optirun (Bumblebee) from IDE (Netbeans, Eclipse)?

前端 未结 4 1515
暗喜
暗喜 2021-01-16 08:00

Does anyone know how to make eclipse or netbeans use the graphics card in optimus laptops by invoking optirun (bumblebee) inside the IDE so that one can just use the run but

4条回答
  •  抹茶落季
    2021-01-16 09:00

    I build the project in Netbeans (F11) and run the following in a terminal:

    optirun java -jar path/to/javaproject/dist/javaproject.jar
    

    Mind that if you have any java parameters in your project, you need to add it manually. My workflow is like this:

    Locate the Java options from the project, open Project -> Properties, Run. At VM Options I see -Djava.library.path=lwjgl/native/windows;:lwjgl/native/linux. I also have some parameters that I want to pass to main(String[]). With this information, I open a terminal and run:

    cd path/to/javaproject
    optirun java -Djava.library.path=lwjgl/native/windows;:lwjgl/native/linux \
        -jar dist/javaproject.jar some paremeters
    

    Another hint, if you have to open and close the program frequently, run optirun bash in a different tab so that preparing the use of the graphics card becomes faster. Alternatively, you can run optirun netbeans, but that means that the nvidia card will always be on even if you are programming which increases power use and increase the heat.

    Important: if you are using a 32-bit JVM or Java libraries on a 64-bit machine, you also need to install the 32-bit drivers and libraries. For Ubuntu, the nvidia package already contains 32-bit drivers, see this answer. For other distros, you likely need to install lib32-* packages for Mesa, VirtualGL and nvidia-utils.

提交回复
热议问题