File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Problem in executing jar with windows 7 64 bit Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Problem in executing jar with windows 7 64 bit" Watch "Problem in executing jar with windows 7 64 bit" New topic
Author

Problem in executing jar with windows 7 64 bit

Gurumoorthy Doraiswamy
Greenhorn

Joined: Jan 15, 2013
Posts: 21
Hi,

I have created a batch file which internally calls the jar and the start up class as below

java -cp "jars/JPLSyncApp-1.0-SNAPSHOT.jar;jars/*" Welcome.App.

I use Netbeans with JDK 1.6 as Default. This file works normally in windows 7 32 bit. But when i try the same with windows 7 64 bit which has JRE 1.7 and try to run the batch file as administrator then i receive the below error message
"could not find or load main class".

i tried to build the app with JDK 1.7 but that too does not work with the 64 bit machine. I am .NET Developer there we have build configuration where we can specify 32 bit or 64 bit. if an application is built against 32 bit it will normally work in 64 bit. But why does this happen here.

Do i need to set any classpath or do i need JRE 6 to run. Please advise.
Mansukhdeep Thind
Ranch Hand

Joined: Jul 27, 2010
Posts: 1157

When the .jar file was created, which JDK did you use, 32 bit or 64 bit?


~ Mansukh
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14435
    
  23

Mansukhdeep Thind wrote:When the .jar file was created, which JDK did you use, 32 bit or 64 bit?

Whatever the answer to that question is, it doesn't matter. There is no 32-bit or 64-bit in the Java world; bytecode is not 32-bit or 64-bit, and class files compiled with a 32-bit JDK will run on a 64-bit JVM and vice versa without any changes.

The only thing I see that's a bit strange is that you use forward slashes / in your classpath, while Windows expects backslashes \ to separate elements in a path (although sometimes Windows seems to understand forward slashes too). You could try using backslashes:

java -cp "jars\JPLSyncApp-1.0-SNAPSHOT.jar;jars\*" Welcome.App

Note also that you have a dot "." after "Welcome.App", I don't know if you're really typing that dot or not. Leave it out. (Details are important!).


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Mansukhdeep Thind
Ranch Hand

Joined: Jul 27, 2010
Posts: 1157

Then why is there a different installable for JDK for 32 bit and 64 bit platforms?
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2718
    
    6

The 32 bit and 64 bit JVMs are different, hence different installables.
Also the Java compiler (.exe) in itself is native, so it has different version for 32 and 64 bit machines.

SCJP, SCWCD.
|Asking Good Questions|
Mansukhdeep Thind
Ranch Hand

Joined: Jul 27, 2010
Posts: 1157

You mean to say that the Java compiler is implemented in native language (like C , C++ etc.). Cool..
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40064
    
  28
Mansukhdeep Thind wrote:You mean to say that the Java compiler is implemented in native language (like C , C++ etc.). Cool..
I don’t think so. I think javac is implemented in Java, but I am not sure. The heap and stack are probably C, however.
Go to the openJDK website and you can download the whole of it and inspect it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem in executing jar with windows 7 64 bit