0

I have a Java class called Xj3DTest and when I run it, I get the following run-time error:

Error: Could not find or load main class java
C:\Users\matt\AppData\Local\NetBeans\Cache\8.1\executor-snippets\run.xml:53: Java returned: 1
BUILD FAILED (total time: 0 seconds)

And in executor-snippets is:

<?xml version="1.0" encoding="UTF-8"?>
    <project name="{0} (run)" default="run" basedir=".">
    <target name="run">        
        <translate-classpath classpath="${classpath}" targetProperty="classpath-translated" />
        <property name="run.jvmargs" value="" />
        <property name="work.dir" value="${basedir}"/>
        <property name="application.args" value="" />
        <property name="java.failonerror" value="true"/>
        <java classpath="${classpath-translated}" classname="${classname}" dir="${work.dir}" jvm="${platform.java}" fork="true" failonerror="${java.failonerror}">
            <jvmarg value="-Dfile.encoding=${encoding}"/>
            <redirector inputencoding="${encoding}" outputencoding="${encoding}" errorencoding="${encoding}"/>
            <jvmarg line="${run.jvmargs}" />
            <arg line="${application.args}" />
            <syspropertyset>
                <propertyref prefix="run-sys-prop."/>
                <mapper from="run-sys-prop.*" to="*" type="glob"/>
            </syspropertyset>
        </java>
    </target>
</project>

Also, I've been getting an error saying that SEVERE: Native code library (32 and 64 bit library) failed to load: java.lang.UnsatisfiedLinkError: no odejava in java.library.path java.lang.UnsatisfiedLinkError: no odejava in java.library.path and I've done some research and found that System.getProperty("sun.arch.data.model") helps, but I've not found where it goes. I'm using Windows 10 and Netbeans 8.1.

smitthy
  • 307
  • 4
  • 18
  • The failure to find the native library is most likely the root cause of the "Could not find or load main class java" error. IMO Java is a bit misleading with error messages when class load failure is caused but missing native lib. What is your java.library.path and is odejava lib on that path? – JJF Apr 01 '16 at 14:11
  • @JJF The java.library.path for the odejava `C:\Users\matt\Documents\NetBeansProjects\natives\Windows 10\amd64` and `C:\Users\matt\Documents\NetBeansProjects\natives\Windows 10\x86_64` and the way that I've got it in the VM Options in Netbeans is ` java -Djava.library.path="..."` filled with each of the above. I don't know what version of Java I'm using but the `dll` file that I have is `odejava64.dll`. – smitthy Apr 01 '16 at 16:32
  • Looks like that .dll is a 64 bit dll. You need to make sure that you are running a 64 bit JVM. You can't load a 64 bit native library in a 32 bit JVM or vice versa. – JJF Apr 01 '16 at 18:26
  • @JJF How would I go about checking what bit JVM I have? – smitthy Apr 01 '16 at 21:35
  • See http://stackoverflow.com/questions/2062020/how-can-i-tell-if-im-running-in-64-bit-jvm-or-32-bit-jvm-from-within-a-program – JJF Apr 01 '16 at 23:36
  • @JJF I've read through that, which is where I got the `System.getProperty("sun.arch.data.model")` from. and I was wondering where abouts I put that. – smitthy Apr 02 '16 at 09:17
  • @JJF I've found that the version of Netbeans 8.1 I have is 32 bit; I've run the following `System.out.println(System.getProperty("sun.arch.data.model"));` in a new project as whenever I ran it in my Xj3DTest class, I always got the error detailed in the question. – smitthy Apr 02 '16 at 10:05
  • You probably need to install a 64 bit JVM. Not a Netbeans user so I can't tell you how to configure NB to use a 64 bit JVM. Again I'm thinking that the .dll is a 64 bit dll based on its name 'odejava64.dll'. Or you could see if there is a 32 bit version of that .dll. – JJF Apr 02 '16 at 13:20

0 Answers0