How can I run an example in cloudsimSDN? - java

I can't run the CloudSimSDN via cmd (Command Prompt) and I can't run that via eclipse, too.
I installed eclipse 4.6.0, JDK 1.8.0. The cloudSimSDN needs CloudSim-3.0.3, apache Commons Math, json-simple-1.1.1 and guava-17.0.
I have given below the errors. Could you tell me know what needs to be done?
When I try to execute the example using the following command:
java -cp ./*:. org/cloudbus/cloudsim/sdn/example/SDNExample MFF dataset-energy/energy-physical.json dataset-energy/energy-virtual.json dataset-energy/energy-workload.csv > results.out
java -cp ./*:.This code needs to be write in special directory? Or -cp ./*:. is a special switch in java?(please explain about it. I am beginner in cloudsim, Help me please.
Below are the error codes:
Could not find or load main class org.cloudbus.cloudsim.sdn.example.SDNExample.
My reference of source code: CloudSimSDN

please go through steps mentioned here at tantrabhavan.blogspot.com. It worked for me!!!!

Related

Java don't run the main file (classpath)

Hello guys i'm new with java and i'm starting to work with packages etc, i have a problem when i try to run my main file located at
C:\Users\Robert\Desktop\Java\latebd\Test.Java
When i run
java -cp C:\Users\Robert\Desktop\Java\latebd\latebd.Test
instead of having the code running i get this (it's in italian bu basically it's telling all the options when i use java -
Why do i get that?
you need to compile it e.g. javac C:\Users\Robert\Desktop\Java\latebd\*
provide the path where it's already compiled as a classpath, and to run it use java -cp "C:\Users\Robert\Desktop\Java\latebd\*" latebd.Test
Try java -cp "C:\Users\Robert\Desktop\Java\latebd\latebd.Test"

Issue running tensorflow with java

I am having some issues running tensorflow with java. I am using CUDA 8 with CuDNN 6.
I tried following the quickstart instructions located here: https://www.tensorflow.org/install/install_java and get the following error message when I attempt to run the example java program:
java -cp libtensorflow-1.4.0.jar:. -Djava.library.path=./jni HelloTF
Exception in thread "main" java.lang.UnsatisfiedLinkError: Cannot find TensorFlow native library for OS: linux, architecture: x86_64. 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:75)
at org.tensorflow.TensorFlow.init(TensorFlow.java:66)
at org.tensorflow.TensorFlow.<clinit>(TensorFlow.java:70)
at org.tensorflow.Graph.<clinit>(Graph.java:258)
at HelloTF.main(HelloTF.java:8)
The jni directory contains the following:
libtensorflow_framework.so
libtensorflow_jni.so
LICENSE
I then tried installing the binaries from source as suggested here:
https://github.com/tensorflow/tensorflow/blob/master/tensorflow/java/README.md
This is the output from setting: org.tensorflow.NativeLibrary.DEBUG=1
org.tensorflow.NativeLibrary: tryLoadLibraryFailed: /path/to/jni/libtensorflow_jni.so: libcublas.so.8.0: cannot open shared object file: No such file or directory
org.tensorflow.NativeLibrary: jniResourceName: org/tensorflow/native/linux-x86_64/libtensorflow_jni.so
org.tensorflow.NativeLibrary: frameworkResourceName: org/tensorflow/native/linux-x86_64/libtensorflow_framework.so
But I still get the same error message when I try and run the example Java program.
What am I doing wrong??
Any help would be greatly appreciated!
The error
Cannot find TensorFlow native library for OS: linux, architecture: x86_64.
is clearly stating that the library is not visible to your software.
To make it available to the Java class, try doing like that (in the same shell obviously):
export LD_LIBRARY_PATH=/the/absolute/path/to/your/library
java -cp libtensorflow-1.4.0.jar:. -Djava.library.path=./jni HelloTF
also ensure you're running the java command from the same directory which contains the /jni directory.
For those landing here and facing the same issue.
You are probably trying to run your program from eclipse. Then, you have to go to Run configurations > Arguments and pass this arguments:
Program arguments -> models/
images/example-400x288.jpg
VM Arguments -> -Djava.library.path=./jni
like in this screenshot:
When people (like myself) come from python to java world, everything is strange! here is how I solved my problem regarding all linking errors:
I assumed you already have simple hello Tensorflow project, explained here
Download and copy tensorflow JNI files to :/usr/lib/tensorflow
Download and copy desired version of tensorflow Lib jar file to: /usr/lib/tensorflow
Compile with java
Compile java file
javac -cp /usr/lib/tensorflow/libtensorflow-1.14.0.jar HelloTensorFlow.java
run java file:
java -cp /usr/lib/tensorflow/libtensorflow-1.14.0.jar:. -Djava.library.path=/usr/lib/tensorflow/ HelloTensorFlow
use MAVEN
First we should export LD_LIBRARY_PATH:
export LD_LIBRARY_PATH=/usr/lib/tensorflow
Then run maven build command:
mvn -q compile exec:java
I hope it helps you

Unable to find a java runtime

I got an error when I run a file exe.
unable to find a java runtime, please download and install a java runtime from http://www.borland.com/jbuilder/resources/javaruntime.html
I use Java 1.8.0_151.
To fix it, I know I can run: javaw -jar exe_name class_name in cmd.
Ex: javaw -jar soflW.exe org.jgraph.JGraphad, but I don't know how to find the class name?
I have found a solution to my problem.
To find class name: I need zip .exe file and open it by winzip, then open file manifest.mf and you can see class name.
In my case, I need run with Java 7 because Java 8 hasn't this class and use java instead of javax as I said.
In other cases, I can run with Java 8 and use javax. I have not tried with java yet.

File not found exception when running with intellj

I'm trying to run my application through intellji so I can debug.
When I run this command from the terminal it works:
java -cp /Users/craigharley/code/IdeaProjects/decaf-CraigHarley/Skeleton/lib/antlr-4.6-complete.jar:Compiler.jar decaf.Main -target inter /Users/craigharley/code/IdeaProjects/decaf-CraigHarley/Skeleton/testdata/semantics/illegal-cust.dcf
But when I create a build using:
Edit Build Configs
New Application
Select the main class
Enter -cp /Users/craigharley/code/IdeaProjects/decaf-CraigHarley/Skeleton/lib/antlr-4.6-complete.jar:Compiler.jar decaf.Main -target inter /Users/craigharley/code/IdeaProjects/decaf-CraigHarley/Skeleton/testdata/semantics/illegal-cust.dcf as the program arguments I get a file not found on the /Users/craigharley/code/IdeaProjects/decaf-CraigHarley/Skeleton/lib/antlr-4.6-complete.jar:Compiler.jar, anyone know why this is?
I assume it's because of the :Compiler.jar, I don't java much so could somebody explain this to me.
Thanks

Running a java program using -cp

so I've checked many posts here and tried everything people suggested and I'm still getting "Could not find or load main class" error, and my professor wasn't very helpful in his answer when I asked for help.
This is what my professor said is supposed to work (he is using OSX).
java -cp classes:lib/json.jar cst420.jsonrpc.client.GroupServerJavaStub http://127.0.0.1:8080
After reading some other posts on this site, I also tried:
java -cp classes:"lib/json.jar" cst420.jsonrpc.client.GroupServerJavaStub http://127.0.0.1:8080
java -cp "lib/json.jar" cst420.jsonrpc.client.GroupServerJavaStub http://127.0.0.1:8080
Still nothing works. I'm in the base directory in a bash prompt ~\GroupJsonRPC and the class file that is in ~\GroupJsonRPC\classes\cst420\jsonrpc\client\GroupServerJavaStub.class exists and is ready for running. The same goes for ~\GroupJsonRPC\lib\json.jar. Any insight into how to get this darn thing running would be greatly appreciated!
PS: I'm using Windows.
The proper command is:
java -cp "classes;lib/json.jar" cst420.jsonrpc.client.GroupServerJavaStub http://127.0.0.1:8080
You need to be sure to include the directory of your class files as well as the jar file(s) with ';' separators, and don't use the -jar option. It invalidates the -cp option.

Categories