Cannot use installed java 3d - java

hi i'm trying to use java 3d in both command prompt and in netbeans. I have a win8 64 bit computor. I installed j3d-1_5_2-windows-amd64.exe. and it got installed inside java folder in a folder called Java3D. then I added an environmental variable as CLASSPATH and the values are C:\Program Files\Java\Java3D\1.5.2\lib\ext\j3dcore.jar;C:\Program Files\Java\Java3D\1.5.2\lib\ext\j3dutils.jar;C:\Program Files\Java\Java3D\1.5.2\lib\ext\vecmath.jar.
my file get compilled without errors when I try to runit from command prompt using the command java -cp . Hello3d it gives a calss not found error for javax/media/j3d/Node. and when i try to import 3d libraries from netbeans it gives an error on j3d after import com.sun. the following is the class I compiled from command prompt. please tell me what i'm doing wrong. thanx in advance
import com.sun.j3d.utils.universe.SimpleUniverse;
import com.sun.j3d.utils.geometry.ColorCube;
import javax.media.j3d.BranchGroup;
public class Hello3d {
public Hello3d()
{
SimpleUniverse universe = new SimpleUniverse();
BranchGroup group = new BranchGroup();
group.addChild(new ColorCube(0.3));
universe.getViewingPlatform().setNominalViewingTransform();
universe.addBranchGraph(group);
}
public static void main( String[] args ) {
new Hello3d();
}
} // end of class Hello3d

You use an obsolete version (1.5.2) of Java3D, this version is no longer maintained since a few years. Please uninstall it and install the latest version (1.6.0). Follow my instructions here.

Your code runs perfectly in my eclipse environment using java3d version 1.5.2.
It shows an ugly cube seen from one side only, red faced.
I guess you need to set the path to the native libraries that java3d needs.
Regrettably, I don't know how to do this on windows (R).
Regrettably I have not enough reputation to put this into a comment rather than an answer.
If anyone with enough reputation cares, please turn this answer into a comment.

Related

Ensuring files are available to the JVM

I'm trying to install TensorFlow for Java on Windows 10 using this Article
. I followed the steps carefully but the windows commands didn't work with me so I decided to do it manually.
The first command is to make the .jar part of the classpath and I did it manually
but the second step was to ensure that the following two files are available to the JVM: the .jar file and the extracted JNI library
but I don't know how to do that manually
The code:
package securityapplication;
import org.tensorflow.TensorFlow;
import org.tensorflow.Graph;
import org.tensorflow.Session;
import org.tensorflow.Tensor;
public class SecurityApplication {
public static void main(String[] args) throws Exception {
try (Graph g = new Graph()) {
final String value = "Hello from " + TensorFlow.version();
// Construct the computation graph with a single operation, a constant
// named "MyConst" with a value "value".
try (Tensor t = Tensor.create(value.getBytes("UTF-8"))) {
// The Java API doesn't yet include convenience functions for adding operations.
g.opBuilder("Const", "MyConst").setAttr("dtype", t.dataType()).setAttr("value", t).build();
}
// Execute the "MyConst" operation in a Session.
try (Session s = new Session(g);
Tensor output = s.runner().fetch("MyConst").run().get(0)) {
System.out.println(new String(output.bytesValue(), "UTF-8"));
}
}
}
}
could someone help? cuz my program that uses TensorFlow still have the following error
The text in the image is :
Exception in thread "main" java.lang.UnsatisfiedLinkError: Cannot find TensorFlow native library for OS: windows, architecture: x86. See https://github.com/tensorflow/tensorflow/tree/master/tensorflow/java/README.md for possible solutions (such as building the library from source). Additional information on attempts to find the native library can be obtained by adding org.tensorflow.NativeLibrary.DEBUG=1 to the system properties of the JVM.
at org.tensorflow.NativeLibrary.load(NativeLibrary.java:66)
at org.tensorflow.NativeLibrary.load(NativeLibrary.java:66)
at org.tensorflow.TensorFlow.init(TensorFlow.java:36)
at org.tensorflow.TensorFlow.<clinit>(TensorFlow.java:40)
at org.tensorflow.Graph.<clinit>(Graph.java:194)
at securityapplication.SecurityApplication.main(SecurityApplication.java:15) Java Result: 1 BUILD SUCCESSFUL (total time: 4 seconds)
The result after running the first command in cmd:
The result after running the second command in Windows PowerShell:
Any suggestions?!
Thank you
The first command failure (javac) suggests that the javac command is not in your PATH environment variables. See for example, this StackOverflow question
For the second command failure, I believe the space after -D is what is causing you trouble as Holger suggested.
IDEs like Eclipse and others also provide a means to set the java.library.path property for the JVM (see this StackOverflow answer for example).
Background: TensorFlow for Java consists of a Java library (packaged in a .jar file) and a native library (.dll on Windows, distributed in a .zip file). You need to ensure that the .jar file is in the classpath and the directory containing the .dll is in included in the java.library.path of the JVM when executing a program.
Hope that helps.

ACM Library simple example not working with jdk 1.7.0_79

Hi All java Experts!
When I tried a little example of acm library
import acm.program.*;
class prog extends ConsoleProgram {
public void run() {
int number = readInt("?");
println("You entered: " number);
}
}
It compiled successfully.
I used commandline like this:
javac -cp acm.jar; main.java
java -cp acm.jar; prog
But I got this error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: acm.util.DOSCommandLi
ne.getLine()Ljava/lang/String;
at acm.util.DOSCommandLine.getLine(Native Method)
at acm.util.DOSCommandLine.getCommandLine(JTFTools.java:1627)
at acm.util.JTFTools.getCommandLine(JTFTools.java:439)
at acm.util.JTFTools.getMainClass(JTFTools.java:464)
at acm.program.Program.main(Program.java:1320)
What does it mean... I think the JDK version problem.... however I am using JDK 'jdk1.7.0_79'
In my opinion It is throwing exception only for this JDK version. Request to try you and give feedback.
Thanks...
Solved!
It doesn't require any native library...
What I had to do was to Use main entry as:
public static void main(String[] args) {
new prog().start(args);
}
Adding after 'run' method it works now. Note: this line 'new prog().start(args);'
This solution found here:
http://www.dreamincode.net/forums/topic/240789-acmjar-package-problem-class-wasnt-find-in-project/
Thanks Choppy
But it took me considerable time Hushhhhh.....
UnsatisfiedLinkError at Native Method means that there is no native library (for windows it would be dll) loaded which could be called for your acm.util.DOSCommandLine.getLine() method.
With your library there should be native packages, which will contain native libraries for your system architecture. You have to put one of these into your classpath folder.

Libgdx tutorial: cannot open desktop application

I'm trying to follow through the libgdx tutorial (https://code.google.com/p/libgdx/wiki/ProjectSetupNew), but I can't run the Desktop Application. I read up on this, and some people said this would be caused by missing jar files. I went back and made sure that the application was referencing the main project, and that I used the three jar files necessary: gdx-natives.jar, gdx-backend lwjgl.jar, and gdx-backend-lwjgl-natives.jar. Still, when I try to run the application, a window pops up for a second and then crashed, and I get this error:
JavaVM WARNING: JAWT_GetAWT must be called after loading a JVM
_NSJVMLoadLibrary: NSAddLibrary failed for /libjawt.dylib
JavaVM FATAL: lookup of function JAWT_GetAWT failed. Exit
AL lib: ReleaseALC: 1 device not closed
Any ideas why this is happening? As a side note, some forums said that JRE 7 was causing a problem before, but it has since been fixed. I am using JRE 1.7.0_17. I'm really stuck on this, and any help would be much appreciated.
The code looks like this:
package com.me.mygdxgame;
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
public class Main {
public static void main(String[] args) {
LwjglApplicationConfiguration cfg = new LwjglApplicationConfiguration();
cfg.title = "my-gdx-game";
cfg.useGL20 = false;
cfg.width = 480;
cfg.height = 320;
new LwjglApplication(new MyGdxGame(), cfg);
}
}
I'm going to guess you're on a Mac. I think its still the JDK7 bug. The problem is with the combination of LWJGL+Mac+Java. I believe Libgdx has not upgraded to the bleeding edge of LWJGL (which may have fixed the problem?) because of other problems that the upgrade introduces (though I'm not entirely positive of this).
If you're on a Mac, then your question is probably a dup to this one:
Can't load libgdx desktop app on mac osx

help with Eclipse Memory Analyzer [MAT]

I tried using MAT as per this link but dont see (.hprof) file generated anywhere after running the code. I used the -XX:+HeapDumpOnOutOfMemoryError in config arguments as mentioned.
Any specific permissions etc I need to get it working ?
P.S:
For context on why I am using the mem analyzer please check the question here:
I had an older version of MAT installed. I installed the newer one and it worked fine in eclipse. thought the older version shld also have worked imo
No special permissions are needed.
I've created a simple class:
public class A {
public static void main(String[] argv) {
String a = "3";
while (true) {
a = a + a;
}
}
}
Then compiled it:
javac A.java
And then ran it:
java -Xmx1m -XX:+HeapDumpOnOutOfMemoryError A
and got the dump file (.hprof).
How does it differ from your procedure?

how can I check the compiler and runtime in netbeans?

in one of my questions ,somebody said that I have to make sure that I'm not using compiler 1.6 and 1.5 runtime when i want to execute or debug my program,but I don't know how can i check compiler and runtime in NetBeans ,I am beginner with NetBeans.
my question was:
**I debug my project and the result was :
debug: Have no FileObject for C:\Program Files\Java\jdk1.6.0_02\jre\lib\sunrsasign.jar
Have no FileObject for C:\Program Files\Java\jdk1.6.0_02\jre\classes**
what should i do?
and he answers : you have to make sure that you are not using compiler 1.6 and 1.5 runtime when you want to execute or debug your program
Here's what I use to find out everything about my building environment (never felt too warm with Eclipse):
import static java.lang.System.out;
public class Zeug {
static String[] opts = new String[] { "java.version", "java.vendor",
"java.vendor.url", "java.home", "java.vm.specification.version",
"java.vm.specification.vendor", "java.vm.specification.name",
"java.vm.version", "java.vm.vendor", "java.vm.name",
"java.specification.version", "java.specification.vendor",
"java.specification.name", "java.class.version", "java.class.path",
"java.library.path", "java.io.tmpdir", "java.compiler",
"java.ext.dirs", "os.name", "os.arch", "os.version",
"file.separator", "path.separator", "line.separator", "user.name",
"user.home", "user.dir" };
public static void main(String[] args) {
for(String o : opts) {
out.println(o + ": " + System.getProperty(o));
}
}
}
Go to Tools-->Java Platform and you should see the JDK you are using listed. I am using java-6-sun-1.6.0.16 which does indeed have the jar file you need.
Download the latest JDK from Sun. Go to Tools-->Java Platform and click Add Platform. Navigate to where you installed the latest JDK, name it something meaningful like JDK 1.6.0.16 or whatever and click Finish. Right click on the top level of your project and click Properties. At the top of the popup window change the Java Platform to the one you just added and click ok. At that point, you should not experience your current problem when you compile.
JDK Download Link
You can set the Java version to be used in the project properties (right click on the project).
Edit: after seeing your specific error message: this seems to be a deeper problem. For some reason Netbeans is looking for a file sunrsasign.jar, which is not normally part of the JDK. Looking for the filename on Google indicates that it's part of a cryptography extension, but that seems to have been integrated into the JDK by now. So the JAR is not needed anymore.
I don't know whether it's Netbeans (are you using the most recent version?) or your application that is mistakenly looking for a JAR that has been integrated into the JDK library itselt.

Categories

Resources