Results 1 to 12 of 12
Thread: Small JAR problem
- 12-16-2011, 07:03 AM #1
Member
- Join Date
- Oct 2011
- Posts
- 13
- Rep Power
- 0
Small JAR problem
Hello all !
I discovered how to make .jar files, using the cmd console.
I made a .jar simply by defining the entry point class with the following syntax:double clicking the actual .jar file via windows explorer yields : "Cannot find the main class: TimeViewer. Program will exit." error message, but running the jar through the console with the appropriate syntax works fine. Its exactly the same if I make the Manifest.txt myself and create the .jar withJava Code:jar cfe Test.jar TimeViewer *.class
Fine through console but not double clicking.Java Code:jar cfm Test.jar Manifest.txt *.class
can someone please help?
thanks! ^^
- 12-16-2011, 11:00 AM #2
Banned
- Join Date
- Dec 2011
- Posts
- 143
- Rep Power
- 0
- 12-16-2011, 03:38 PM #3
Member
- Join Date
- Oct 2011
- Posts
- 13
- Rep Power
- 0
Re: Small JAR problem
yes, here be the content of my (self made) Manifest :
Main-Class: TimeViewer
and I pressed 'enter' after TimeViewer for carriage return, so its actually two lines, second one being empty but making sure the 'blinking' vertical line is at the start of the second line.
- 12-16-2011, 03:43 PM #4
Banned
- Join Date
- Dec 2011
- Posts
- 143
- Rep Power
- 0
Re: Small JAR problem
Is there a package statement in your source?
- 12-16-2011, 04:39 PM #5
Member
- Join Date
- Oct 2011
- Posts
- 13
- Rep Power
- 0
Re: Small JAR problem
In the source code you mean? No, no mention of packages.
If I change the manifest to
Main-Class: JClock.TimeViewer
to include the package name, it won't even run from cmd. The error message I get is
Error:Could not find or load main class JClock.TimeViewer
PS: I realise case sensitivity is very important and I've made sure that everything corresponds.
- 12-16-2011, 05:05 PM #6
Member
- Join Date
- Oct 2011
- Posts
- 13
- Rep Power
- 0
Re: Small JAR problem
arggh.. I just followed a simple video tutorial involving just one class file, I did everything same as the 'tutor', and as usual same problem. I can run the jar file from the console it launches it accordingly, but double clicking from windows explorer I keep getting the same 'Could not find the main class: Hello'
The tutorial included showing how to make a proper manifest so I know I got it right.
- 12-16-2011, 05:07 PM #7
Member
- Join Date
- Oct 2011
- Posts
- 13
- Rep Power
- 0
Re: Small JAR problem
ironically, double clicking a JAR file made by someone else involving my code (so exactly the same) works.. just not when I make it.
- 12-16-2011, 05:22 PM #8
Banned
- Join Date
- Dec 2011
- Posts
- 143
- Rep Power
- 0
Re: Small JAR problem
What does jar tf Test.jar give you?
- 12-16-2011, 05:48 PM #9
Member
- Join Date
- Oct 2011
- Posts
- 13
- Rep Power
- 0
Re: Small JAR problem
that gives me (working on the single class case now) :
META-INF/
META-INF/MANIFEST.MF
Hello.class
- 12-16-2011, 05:57 PM #10
Banned
- Join Date
- Dec 2011
- Posts
- 143
- Rep Power
- 0
Re: Small JAR problem
...hmmm....so...
When you double click a jar, it launches javaw.exe..
Is the other persons version of Java different from yours? Do you both get the same thing with java -version
- 12-16-2011, 06:15 PM #11
Banned
- Join Date
- Dec 2011
- Posts
- 143
- Rep Power
- 0
Re: Small JAR problem
OK, I'm off for a while..but before I go, ideas...
1. Your version of Java is different from your version of javaw.exe
2. If you move your jar to an empty directory, can you still run it from the command line?
3. If you extract using jar xf Test.jar, (in your empty directory, so that you don't overwrite anything), does your manifest file have the expected entries.
- 12-16-2011, 07:16 PM #12
Member
- Join Date
- Oct 2011
- Posts
- 13
- Rep Power
- 0
Re: Small JAR problem
awesome, got it to work now. there was a problem in version as you guessed. I must have been confused when installing Java initially and editing the "environment"'s path, between Program Files and Program Files x86. I fixed it and updated at same time so now it shows "vers. 1.7.0_02" :)
so I got it to work on that example I was working on, with the hello.class; and my 'JClock' =) thanks for all the help ! xDLast edited by Kaizer; 12-16-2011 at 07:19 PM.
Similar Threads
-
Small problem with problem with Java, C++ parse program.
By dragstang86 in forum New To JavaReplies: 4Last Post: 10-30-2011, 03:43 AM -
small problem, thanks in advance for your help
By farahm in forum New To JavaReplies: 4Last Post: 11-22-2010, 09:26 AM -
small problem
By rawan in forum Java AppletsReplies: 2Last Post: 04-07-2010, 03:32 AM -
small problem
By barusk in forum NetworkingReplies: 4Last Post: 03-21-2009, 06:19 AM -
Small problem
By ayoood in forum New To JavaReplies: 2Last Post: 06-06-2008, 12:27 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks