jar file cause package com.mycomp.crypto does not exist error [message #252506] |
Wed, 26 March 2008 19:26 |
Eclipse User |
|
|
|
Originally posted by: wong_powah.yahoo.ca
A jar file is created by Eclipse wizard and copied to C:\Program
Files\Java\jdk1.5.0_14\jre\lib\ext.
C:\win10\JavaSP\test>javac KeyDisplay.java
KeyDisplay.java:15: package com.mycomp.crypto does not exist
import com.mycomp.crypto.*;
^
1 error
Using the command line to create the jar file
jar -cf MyJCASP.jar com\mycomp\crypto\*.class
com\mycomp\crypto\X509\*.class
and copied to C:\Program Files\Java\jdk1.5.0_14\jre\lib\ext.
It will compile ok.
C:\win10\JavaSP\test>javac KeyDisplay.java
C:\win10\JavaSP\test
Please help.
|
|
|
|
Re: jar file cause package com.mycomp.crypto does not exist error [message #252514 is a reply to message #252510] |
Wed, 26 March 2008 21:14 |
Eclipse User |
|
|
|
Originally posted by: wharley.bea.com
"powah" <wong_powah@yahoo.ca> wrote in message
news:9d449d66cd7aaa15324db5167b28c3a6$1@www.eclipse.org...
> The good jar created by the jar command had the path:
> tar tvf MyJCASP.jar
> com/mycomp/crypto/Key.class
> ..
>
> The bad jar created by eclipse had no path:
> tar tvf MyJCASP.jar
> Key.class
> ..
>
> How to make eclipse v3.3.2 to put the path in the jar file?
If I understand your somewhat confusingly worded question, what you are
saying is that when you generate a jar file from Eclipse, the classes are
ending up at the root of the jar file rather than nested in directories
according to their package.
What steps, exactly, did you take in Eclipse to generate the bad jar file?
I can't reproduce your problem. When I select the project in Package
Explorer and use File -> Export -> Java -> Jar File to export, using the
default settings, I get the folder structure as expected.
|
|
|
Re: jar file cause package com.mycomp.crypto does not exist error [message #252517 is a reply to message #252514] |
Wed, 26 March 2008 21:38 |
Eclipse User |
|
|
|
Originally posted by: wong_powah.yahoo.ca
I set the workspace to C:\temp\eclipse\workspace.
My source files are at C:\win10\JavaSP\com\mycomp\crypto and
C:\win10\JavaSP\com\mycomp\crypto\X509
I create project "Same" and use "Import, File System, Filter Types, Select
Types" menus to put the source files from
C:\win10\JavaSP\com\mycomp\crypto and
C:\win10\JavaSP\com\mycomp\crypto\X509 to C:\temp\eclipse\workspace\Same.
I discover that the com\mycomp\crypto directory are not created in the
C:\temp\eclipse\workspace\Same directory.
Please help to solve this problem.
|
|
|
Re: jar file cause package com.mycomp.crypto does not exist error [message #252531 is a reply to message #252517] |
Thu, 27 March 2008 00:03 |
Eclipse User |
|
|
|
Originally posted by: wharley.bea.com
"powah" <wong_powah@yahoo.ca> wrote in message
news:09ede2362ecb4cefcb91ebd57ec69b99$1@www.eclipse.org...
>I set the workspace to C:\temp\eclipse\workspace.
> My source files are at C:\win10\JavaSP\com\mycomp\crypto and
> C:\win10\JavaSP\com\mycomp\crypto\X509
> I create project "Same" and use "Import, File System, Filter Types, Select
> Types" menus to put the source files from
> C:\win10\JavaSP\com\mycomp\crypto and
> C:\win10\JavaSP\com\mycomp\crypto\X509 to C:\temp\eclipse\workspace\Same.
> I discover that the com\mycomp\crypto directory are not created in the
> C:\temp\eclipse\workspace\Same directory.
> Please help to solve this problem.
When I follow those steps, it still works for me.
Are you sure that you are creating a new Java Project, rather than just a
plain Project?
When you import the files, are you importing them from their appropriate
root folder (i.e., c:\win10\JavaSP) or are you starting lower down in the
hierarchy?
Are you importing them into a source folder in the Java Project?
In the Package Explorer view, do you see the files showing up in their
appropriate packages, or are they showing up at the root?
|
|
|
Re: jar file cause package com.mycomp.crypto does not exist error [message #252567 is a reply to message #252531] |
Thu, 27 March 2008 12:51 |
Eclipse User |
|
|
|
Originally posted by: wong_powah.yahoo.ca
>When you import the files, are you importing them from their appropriate
>root folder (i.e., c:\win10\JavaSP) or are you starting lower down in the
>hierarchy?
I import the files starting lower down in the hierarchy (i.e.
C:\win10\JavaSP\com\mycomp\crypto) because there are other files
C:\win10\JavaSP\com\mycomp\cryptoext which are used to create another jar.
In the Package Explorer view, the files are showing up at the root.
i.e. I do not see "com" nor "mycomp" nor "crypto" in the "src" and its
subdirectory.
Please help.
Thanks.
|
|
|
|
Re: jar file cause package com.mycomp.crypto does not exist error [message #252604 is a reply to message #252578] |
Thu, 27 March 2008 18:10 |
Eclipse User |
|
|
|
Originally posted by: wharley.bea.com
"powah" <wong_powah@yahoo.ca> wrote in message
news:c94e9c846cfb8400c0240738c3776894$1@www.eclipse.org...
> If I select "Create complete folder structure" button in "Import", "File
> system", then win10.JavaSP.com.mycomp.crypto will be created in Package
> Explorer view.
> The resultant jar file will also contain the extra path "win10.JavaSP".
Right, so what you've discovered is that if you import, the package
structure of your project will depend on what root you specify; and that
when you export, the folder structure of the jar file will depend on the
package structure of the project.
The rest should be obvious...
|
|
|
Re: jar file cause package com.mycomp.crypto does not exist error [message #252627 is a reply to message #252604] |
Fri, 28 March 2008 15:53 |
Eclipse User |
|
|
|
Originally posted by: wong_powah.yahoo.ca
It is not obvious to an eclipse newcomer such as me though:(.
I had tried many ways.
1. Create java project with "Project layout", "Create separate folders
for sources and class files", "Folders".
Source folder name "com\mycomp\crypto\jar"
Output folder name "com\mycomp\crypto\jar".
I wonder why two things are created:
com/mycomp/crypto/jar (seem to be a string)
com-mycomp-crypto (seem to be a folder)
Import files to the "com-mycomp-crypto" folder.
Still had problems.
|
|
|
|
Re: jar file cause package com.mycomp.crypto does not exist error [message #252644 is a reply to message #252627] |
Fri, 28 March 2008 17:38 |
Eclipse User |
|
|
|
Originally posted by: wharley.bea.com
"powah" <wong_powah@yahoo.ca> wrote in message
news:50a4de32ae237f31aa0cc1a66a8bae04$1@www.eclipse.org...
> It is not obvious to an eclipse newcomer such as me though:(.
> I had tried many ways.
> 1. Create java project with "Project layout", "Create separate folders
> for sources and class files", "Folders".
> Source folder name "com\mycomp\crypto\jar"
> Output folder name "com\mycomp\crypto\jar".
> I wonder why two things are created:
> com/mycomp/crypto/jar (seem to be a string)
> com-mycomp-crypto (seem to be a folder)
> Import files to the "com-mycomp-crypto" folder.
> Still had problems.
Here's what I'd suggest:
1. Create a new Java project, with separate src and output folders.
2. Copy the Java files you need into that project. You can do this with
Import, or else you can just use the Windows Explorer or a command shell or
whatever, as long as you hit 'F5' in Eclipse afterwards to refresh.
In step 2, you should put the files in a folder structure corresponding to
the package structure you want. So, if your workspace is c:\workspaceA, and
the project is named "foo", the root of the package structure would then be
c:\workspaceA\foo\src; and if you have a class named X.java that is in
package com.xyz.px, it should go in the folder
c:\workspaceA\foo\src\com\xyz\px.
If you use Import to copy the files into the project, you need to import
from the root of the imported project. For instance, if you are importing
the source for com.xyz.px.X, and it is in
c:\stuff\and\junk\com\xyz\px\X.java, you would need to import from
c:\stuff\and\junk, so that the imported file's relative location is
com\xyz\px\X.java.
It would be nice if the Eclipse import wizard were smart enough to open up
the file, see the 'package com.xyz.px;' directive, and put the file in the
appropriate folder no matter where it came from. But it's not,
unfortunately. This would be a good enhancement request.
If you want to explore packages and folders a bit, one approach would be to
go through some of the Eclipse Java tutorials (in the Help, or from the
welcome screen that shows when you create a new workspace), and watch what
happens on disk as you create Java files in Eclipse.
|
|
|
Re: jar file cause package com.mycomp.crypto does not exist error [message #252651 is a reply to message #252644] |
Fri, 28 March 2008 20:19 |
Eclipse User |
|
|
|
Originally posted by: wong_powah.yahoo.ca
You are right. It is working now. Thank you!
I agree 100% with you that "It would be nice if the Eclipse import wizard
were smart enough to open up the file, see the 'package com.xyz.px;'
directive, and put the file in the appropriate folder no matter where it
came from. But it's not, unfortunately. This would be a good enhancement
request."
|
|
|
Powered by
FUDForum. Page generated in 0.07573 seconds