set class path in java from command line .dll file - java

I am using netbeans and by setting the VMoptions to:
-Djava.library.path=C:\Users\a\Desktop\temp\sqljdbc_4.0\enu\auth\x64
my program works perfect. I am trying to run the program from command line. I have tried the following but non seems to be working:
- java -Djava.library.path=C:\Users\a\Desktop\temp\sqljdbc_4.0\enu\auth\x64\sqljdbc_auth.dll
// shows the java usage
- System.setProperty("java.library.path","C:\\Users\\a\\Desktop\\temp\\sqljdbc_4.0\\enu\\auth\\x64");
// wrote it in the code but nothing is happening.
Please let me know if I am doing something wrong or there is an alternative way to do it.

Some suggestions:
Place the DLL in your Windows/<SYSTEM> folder. Make sure to place the right one (32-bit/64-bit). Then try to run it.
Make sure the DLL you are using is the right one. Your Java JRE and NetBeans JRE may be different, e.g., 32-bit JVM vs 64-bit JVM.

Related

The error I get Which checking Apache Pig Version "Error: Could not find or load main class C:\java\lib\tools.jar"

I have my java working properly and also the environment variable is also set for java jdk 1.8.0_261
But when I run the pig -version its shows Error: Could not find or load main class C:\java\lib\tools.jar.
I have also checked the java folder in lib for tools.jar and it is there.
Also the Apache Pig configuration is also correct in pig.cmd
My Hadoop and MapReduce all are working fine with no error.
Your installation is broken, or you have messed up a shell script. That error cannot really mean anything else.
When invoking java.exe, you can either pass a jar file, via java -jar C:\foo.jar, or a classpath + fully qualified class name: java -cp C:\foo.jar;C:\bar.jar com.foo.fullyqualified.ClassName.
That error means you've passed C:\java\lib\tools.jar in the position of that classname. That will fail to run on any system and regardless of installations: C:\java\lib\tools.jar is a file path, not a fully qualified class name. That tools.jar exists in that location is immaterial: It's as if I told you: "I searched for the book titled "Can of Paint" on your bookshelf and I can't find it", and you going: "That's bizarre, because (pointing at the cans of paint on the shelf in the garage), there are cans of paint right here". Java isn't treating that as a path to look up; it is treating it as a class name to search for on the classpath.
Note that this trivial invocation:
java.exe C:\lib\tools.jar
produces the exact error you are observing and that is the correct behaviour of java (because the right way to run it is either java -jar C:\lib\tools.jar or more likely java -cp C:\lib\tools.jar;. com.foo.YourApp. The fix is to.. not invoke java incorrectly like this.
Reasons
Perhaps pig.cmd is broken. The image you pasted does not include the actual call to java.
Perhaps java is broken. Does java.exe work at all? Make some test file, compile it, run it. Does that work?
Perhaps the script is trying to start the jar by letting windows do it (so, double clicking it, or in a script, start foo.jar, which will then end up checking the HKLM registry section for .jar, and then checking the key there for how to start it, and if you've manually edited that, that would break things: You then presumably set it for e.g. java %1 which is broken (it'd have to be java -jar %1).
pig -version doesn't invoke the pig.cmd you think it invokes, but something else.
Something in pig.cmd starts another script. Then that script is broken, or isnt the script pig.cmd thought it was, etc.

Combine CPLEX and JAVA

Java - CPLEX
For a seminar at university I need to program a model with java.
Since it is a maximization problem I also need to involve CPLEX methods. Therefore I successfully installed CPLEX on my Mac OS X Version 10.5.8.
To combine CPLEX and Eclipse (I also tried it with Netbeans) I connected my current project with the CPLEX library (Properties>Library>Add Library).
Eclipse recognizes the library because the methods aren't underlinded. Additionally I committed the following argument to my run configurations:
-Djava.library.path=/Users/myname/Applications/IBM/ILOG/CPLEX_Studio126/cplex/bin/x86-64_osx
When I try to run an exemplary code (that is valid) I get the following error:
java.lang.UnsatisfiedLinkError: /Users/myname/Applications/IBM/ILOG/CPLEX_Studio126/cplex/bin/x86-64_osx/libcplex1260.jnilib: no suitable image found. Did find: /Users/myname/Applications/IBM/ILOG/CPLEX_Studio126/cplex/bin/x86-64_osx/libcplex1260.jnilib: unknown required load command 0x80000022Exception in thread "main" java.lang.UnsatisfiedLinkError: ilog.cplex.Cplex.CPXopenCPLEX([I)J
at ilog.cplex.Cplex.CPXopenCPLEX(Native Method)
at ilog.cplex.CplexI.init(CplexI.java:6594)
at ilog.cplex.CplexI.<init>(CplexI.java:629)
at ilog.cplex.IloCplex.<init>(IloCplex.java:11067)
at ilog.cplex.IloCplex.<init>(IloCplex.java:11082)
at Knapsack.buildModel(Knapsack.java:54)
at Knapsack.main(Knapsack.java:122)
java.library.path must point to the directory containing the CPLEX shared library
try invoking java with java -Djava.library.path=...
could you please be so kind to help me, i don't know any more what to do.
Thank you for an answer
I found this question when having the same problem. followed the advice from the internet and found that I was putting the -Djava.library.path argument in the wrong place... You should really double check not only the paths but also if you put your arguments in the correct place and correctly typed. It seems silly but happens :)
Anyway, in my case, I am using NetBeans, I went to:
Project Properties
Run
in the VM Options text field:
-Djava.library.path=/Applications/IBM/ILOG/CPLEX_Studio126/cplex/bin/x86-64_osx
I hope this will help you
Make sure you closely followed the steps described in 1 for setting up eclipse.
Make sure the environment variable DYLD_LIBRARY_PATH is set in the environment eclipse is running in. See 2. First check if DYLD_LIBRARY_PATH is set. Second try to execute your java program via terminal.

Rake command not found after messing with PATH -- Also, no rails commands work either

Changing my system PATH variable seems to have just screwed up everything.
So, I was trying to run rake device:android:production to make an APK of the app I've been working on with RhoMobile / Rhodes. I got an error telling me that something with my java bin folder was off, so I went and examined my system PATH variable and changed it to my JDK bin folder. It was previously some path that RhoMobile added when I installed it.
So, now I'm getting Rake Command Not Found instead of the java bin folder not found error I was getting before.
I can't run rails server or any rails or gem commands either, and for some reason even commands like ls aren't working for me any more.
How the heck can I get this working again and what did I do?
Changing my PATH allowed me to finally use javac and java commands, but screwed up literally everything else. I am using Windows 7.
That doesn't seem like a Ruby question, but if you're on Windows I assume you're running either the Windows Installer version(rubyinstaller.org) or JRuby?
The PATH variable should contain
c:\ruby200-x64\bin
or
c:\jruby-1.7.3\bin
or the respective path to your local ruby.

I just installed Java Developer and now I do not know how to run it

I just installed Java Developer on Windows Vista. The installation process looked OK and it was successfuly finished. However, I do not know how I cun run this program? Nothing new on the desctop appeared?
First of all it is important to note that the Java Development Kit (JDK) is not a GUI tools such as Visual Studio. It consists mainly of pure command-line tools used to compile, run and debug Java code.
There are IDEs (Integrated Development Environment) which provide the entire Editor/Compiler/Build-System integrated in one big setup, but in my opinion the very first steps should be done with the pure JDK.
Start with this intial Java tutorial.
Generally The Really Big Index should keep you occupied for quite some time.
Fetch yourself a development environment like Eclipse: http://www.eclipse.org/ and start playing around.
The JDK is just that: a software development kit, sitting around in a directory specified by you and waiting for you to invoke its command line tools ...
If by "Java Developer" you mean the Java Development Kit (JDK), then you "run" it via the command line - use javac to compile and java or javaw to run the compiled classes.
If you mean you installed the JDK—the Java development kit—then this is just the Java compiler and the sources of the class library (roughly). You can then go ahead, create Java programs in any text editor and compile them.
But you probably want an IDE, such as Eclipse.
Go to Command Prompt. In the command prompt go to the directory where the Java program is located. In the command line type "java name_of_the_program.java". It will generate name_of_the_program.class. After that you can type (in the command line) "javac name_of_the_program" and the program will be executed.
It is how it should be in theory. But in practice it will not work. To make it work you have to find your java-directory (a directory where "javac.exe" is located). In my case it was "C:\Program Files\Java\jdk1.6.0_18". Then you have to create 4 new environment variables (classpath, include, lib, path) and set them to be equal to the name of the above mentioned directory. After that you need to restart your computer and after that will be able to compile your progam (by typing "javac name_of_the_program.java").
But of couse it is not the end of the story. If you type "java name_of_the_program" the program will not be executed. Java will write you that it is cannot find the main class. How to solve this problem I do not know yet.

JVM Launched via CreateProcess() Loses Classpath Library

I launch the following command line (process) from a Windows VC++ 6 program using CreateProcess (or _spawnv()):
java -cp c:\dir\updates.jar;c:\dir\main.jar Main
and class updates in updates.jar (overiding some in main.jar) are not read or found. It is as if the updates.jar library cannot be found or read.
If I launch the same line from a shortcut, or from the command line proper, everything IS found and executes properly.
If I launch a JVM from the command line, keep it running, AND THEN launch the executable stub (above), then everything works OK also. (This makes it look like the issue is a file rights thing).
Any insight would be greatly appreciated!
--Edward
Try using Microsoft's FileMon utility to figure out what's happening. Set the include filter to "updates" to focus in on the problem.
http://technet.microsoft.com/en-us/sysinternals/bb896642.aspx
Have you tried this on another machine? Another OS? Which JVM are you using? Have you tried different JVMs?
Can you provide us with a minimal example which demonstrates the problem?
Thanks jdigital!
I tried FileMon and it showed me what I was doing wrong. The executable calling CreateProcess() had an unclosed file handle to updates.jar from an attempt to copy the update JAR earlier. Bad code that works in the production environment, but not in the test environment.

Categories

Resources