jar file cause package com.mycomp.crypto does not exist error [message #252506] |
Wed, 26 March 2008 15: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 #252531 is a reply to message #252517] |
Wed, 26 March 2008 20: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 #252644 is a reply to message #252627] |
Fri, 28 March 2008 13: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 16: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.09144 seconds