aspose file tools*
The moose likes Beginning Java and the fly likes package element does not exist Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "package element does not exist" Watch "package element does not exist" New topic
Author

package element does not exist

Farhana Faisal
Greenhorn

Joined: Apr 21, 2006
Posts: 10
Hi,

I am a beginner in Java. I was trying to install JavaElement. I followed all instructions properly to set Environmental Variables (My computer > properties > advanced > Environmental variables). I am using ConText as text editor in xp. When I run following codes:
*****************************************************
import element.*;
public class test
{
public static void main(String[] args)
{
System.out.println("Dit is een test");
}
}
*****************************************************
I get error:
*****************************************************
> Executing: C:\Program
Files\ConTEXT\ConExec.exe "K:\Yava\jdk\bin\javac.exe" "K:\Yava\jdk\test.java"

K:\Yava\jdk\test.java:1: package element does not exist
import element.*;
^
1 error
> Execution finished.
*****************************************************

Please help me!

Thank you.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41872
    
  63
Looking at the program it seems that the line isn't necessary - you can simply delete it. If the "element" package is something that's actually used, then you need to add it to your classpath, either by setting the CLASSPATH environment variable, or by some setting it in your software.


Ping & DNS - my free Android networking tools app
Farhana Faisal
Greenhorn

Joined: Apr 21, 2006
Posts: 10
Hi Ulf,

Thank you for your reply.

The program I think is to check if Element package is working or not. In my case it is not!
My Environemnt variables are as follows:

Use variable name: je
User Variable Values> .; K:\Yava\jdk\lib; K:\Yava\jdk\lib\element.zip

System Variable Name: Path
System Variable> %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\PROGRA~1\COMMON~1\AUTODE~1; K:\Yava\jdk\bin


Still the same problem persists.

Please help me!

Thanks!
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18845
    
  40


Use variable name: je
User Variable Values> .; K:\Yava\jdk\lib; K:\Yava\jdk\lib\element.zip


Java classes are stored in jar files -- which is basically a zip file with extra stuff. Does this element.zip exist? And if it does, is it a valid jar file? And finally, when you list the contents for this jar file, does it contains any classes in the element package?

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Farhana Faisal
Greenhorn

Joined: Apr 21, 2006
Posts: 10
***************************************************************************
Java classes are stored in jar files -- which is basically a zip file with extra stuff. Does this element.zip exist? And if it does, is it a valid jar file? And finally, when you list the contents for this jar file, does it contains any classes in the element package?
***************************************************************************

Hi Henry,

Thank you for your reply.

I have that element.zip file in the lib. But when I go to its properties I find it is a zip file. I unzipped this zip file and the new element folder contains all class file in the same lib folder. I have some executable jar files in this folder but not as in executable jar file in the form of zip file. I am not sure if I could explain or give you any clue.

Regards!
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41872
    
  63
Zip files work just as well as jar files. As long as the element folder is at the top level of the zip file, it should work fine.
Farhana Faisal
Greenhorn

Joined: Apr 21, 2006
Posts: 10
still the same error..Package element does not exist!!

HELPPPPPPPP PLSS!
Farhana Faisal
Greenhorn

Joined: Apr 21, 2006
Posts: 10
ok.

Here is the code to see if my element package is working:
----------------------------
import element.*;
public class test
{
public static void main(String[] args)
{
System.out.println("Dit is een test");
}
}
-----------------------------
upon compiling I get this error:
-----------------------------
> Executing: C:\Program Files\ConTEXT\ConExec.exe "C:\j2sdk1.4.2_11\bin\javac.exe" "C:\j2sdk1.4.2_11\test.java"

C:\j2sdk1.4.2_11\test.java:1: package element does not exist
import element.*;
^
1 error
> Execution finished.
----------------------------
My Environemntal variables are set as follows:
----------------------------
User variable CLASSPATH:
CLASSPATH=.;C:\j2sdk1.4.2_11\lib;c:\j2sdk1.4.2_11\lib\element.zip

System Variables append the following to the variable Path:
;C:\j2sdk1.4.2_11\bin

I installed Java from K:\ to C:\ in the hoope of "By any chance"!!! But the same error.....................

Pls Help!

Thanks!
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41872
    
  63
Just to make sure one more time: the "element" folder that contains the classes is at the top level of the element.zip file?

Does it work if you unzip the file, and add the folder containing the element folder to your classpath?
Farhana Faisal
Greenhorn

Joined: Apr 21, 2006
Posts: 10
Does it work if you unzip the file, and add the folder containing the element folder to your classpath?

(For Ulf)

- Just to make sure one more time: the "element" folder that contains the classes is at the top level of the element.zip file?
1. What do you mean by top level? like..\element\element.zip?
-Just to make sure one more time: the "element" folder that contains the classes is at the top level of the element.zip file?
2.It works with the following error:
-----------------------------------
> Executing: C:\Program Files\ConTEXT\ConExec.exe "C:\j2sdk1.4.2_11\bin\java.exe" test

java.lang.NoClassDefFoundError: test
Exception in thread "main"
> Execution finished.
-----------------------------------
Now what..
:roll:
Farhana Faisal
Greenhorn

Joined: Apr 21, 2006
Posts: 10
Does it work if you unzip the file, and add the folder containing the element folder to your classpath?
---------------------------------------------
It works like charm! THANK YOU!
But then this new killer! As I try to run this simple program!
---------------------------------------------
class HelloWorld {
//
public static void main (String args[]) {
System.out.print("Hello World ");
}
}
---------------------------------------------
The error:
---------------------------------------------
> Executing: C:\Program Files\ConTEXT\ConExec.exe "C:\j2sdk1.4.2_11\bin\java.exe" test

java.lang.NoClassDefFoundError: test
Exception in thread "main"
> Execution finished.
---------------------------------------------
My environmental variables:
---------------------------------------------
User variables values: set CLASSPATH=.;C:\j2sdk1.4.2_11\lib; c:\j2sdk1.4.2_11\lib\element; C:\j2sdk1.4.2_11\bin
SYstem variable values: .;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\PROGRA~1\COMMON~1\AUTODE~1; C:\j2sdk1.4.2_11; C:\j2sdk1.4.2_11\bin\
---------------------------------------------
Help Pls!

Thank you in advance once again!
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14150
    
  18

Why do you try to run "java test"?
Your class is called HelloWorld, not test.

Try "java HelloWorld".


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Farhana Faisal
Greenhorn

Joined: Apr 21, 2006
Posts: 10
I am sorry for that mistake. FOr any program the error is the same! Test or HelloWorld whatever is tried!

Any more ideas?

Thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: package element does not exist