• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Problem compiling java class

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm having trouble finding java on a macosx thru terminal. i can't recall what i typed on Terminal but i got this message "Could not create the Java virtual machine." could anyone tell by that whether or not my mac includes java sdk? Thanks

Miric
[ September 25, 2004: Message edited by: Bear Bibeault ]
 
Sheriff
Posts: 67754
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As far as I know, Java comes pre-installed. I always install the developer tools so I'm not 100% sure it's in the base pacvage (but I'm pretty sure it is).

It doesn;t sound like Java is missing, but more like that something is preventing the JVM from starting properly. What that might be I do not know.

Have you visited the Apple Support site and searched for this issue?
 
blacksmith
Posts: 1332
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A virtual machine comes preinstalled; the JDK does not, but comes with the developer tools.
 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
AFAK
OSX come with JDK installes.
if java -version is not workign means u are log in as wrong user or soemthing.
chack out /System/Library/Frameworks/JavaVM.framework/Versions/
for current version of Java been used.

Latest update available is Java 1.4.2_05
or what is commonly known as
Java 1.4.2.Update 1
 
Miric Ubaydov
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you all. it seems to be found.

although, i have been trying to test one programming that prints messages to the screen prompting the user for her name and her "lucky number', but it doesn't seem to compile and it says that the code has errors which i am sure that it's all correct. Also I am wondering maybe there are specific java commands for mac? is there anything i'm missing below?





[ September 25, 2004: Message edited by: Miric ]

[ September 25, 2004: Message edited by: Miric ]
[ September 25, 2004: Message edited by: Miric ]
 
Bear Bibeault
Sheriff
Posts: 67754
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Miric",

We're pleased to have you here with us on the Ranch, but there are a few rules that need to be followed, and one is that proper names are required. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
Forum Bartender
 
Bear Bibeault
Sheriff
Posts: 67754
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Also I am wondering maybe there are specific java commands for mac?



Nope. Java is Java, even on the Mac.

It appears that the cs1 package is not in your compilation classpath.

Since your problem is no longer Mac-specific, I'm moving this along to the Java in General(beginner) forum.

I'll also change the title as appropriate.
[ September 25, 2004: Message edited by: Bear Bibeault ]
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As Bear pointed out, you're having a CLASSPATH problem. The class cs1.Keyboard being used by your program must be locatable through the CLASSPATH, but it isn't. I'd guess this class was provided by your instructor, or it came with the materials you're studying.

As I mentioned, this class must be locatable through the CLASSPATH. For example, if you put it in the /java folder (which would mean that the class file Keyboard.class would be in /java/cs1), then the following commands should work for compiling and running your Lucky program.

javac -classpath .:/java Lucky.java
java -classpath .:/java Lucky

(On a Windows machine, those colons would be semicolons.)

If this cs1.Keyboard class is something that you'll be using a lot, or if there are other classes that are part of this cs1 package, you might want to edit your operating system CLASSPATH environment variable in a more permanent manner, so that you don't have to always type -classpath .:/java when compiling and running Java programs. For instructions on how to do that, I recommend taking a look at our FAQ on how to set the CLASSPATH. I believe the section on Linux also applies to the Mac OS.
 
Miric Ubaydov
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dirk Schreckmann,

i'm sorry if it may seem a silly question to you, but where do i get cs1 in order to locate for example in java folder?

i followed the link "our FAQ on how to set the CLASSPATH" but i'm having a hard time to understand what it's saying.

If you are using bash as your command shell, open .bash_profile in your favorite text editor. You should already have one in your home directory. If not, you can create it. If use another shell (i.e. ksh, csh, etc.), they run similar profile scripts when loging in. I don't know what the file names are for these other shells, though. If all else fails, you should be able to use .profile instead, which is usually executed no matter which shell you use. For my text editor, I like emacs, so the command line looks something like this:


emacs .bash_profile

The syntax is similar to the autoexec.bat file in Windows 9x/ME. Add something similar to the following lines to the .bash_profile file:


CLASSPATH=.:/usr/local/fubar/Foo.jar:/home/johndoe/myclasses
export CLASSPATH



when i create .bash_profile thru emacs, then there is a new file window and i put the following "CLASSPATH=.:...". then how can i complie to create a class cs1.Keyboard?
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you have the source code for cs1.Keyboard? Is this something you're supposed to create as part of your assignment? Did your instructor give you a cs1.Keyboard class? Is it something from your learning materials that is perhaps downloadable from a website?
[ September 28, 2004: Message edited by: Dirk Schreckmann ]
 
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How to compile cs1.Keyboard ?

Example on Windows OS.

source code in c:/src
class file in c:/classes

Code in c:/src/cs1/Keyboard.java

Compile cs1.Keyboard.java
1. cd c:/src/cs1
2. set p=c:/classes
3. set CLASSPATH=.;%p%;%CLASSPATH%
4. javac -d %p% Keyboard.java
5. Keyboard.class should be created in c:/classes/cs1 directory
 
Miric Ubaydov
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Dirk Schreckmann:
Do you have the source code for cs1.Keyboard? Is this something you're supposed to create as part of your assignment? Did your instructor give you a cs1.Keyboard class? Is it something from your learning materials that is perhaps downloadable from a website?

[ September 28, 2004: Message edited by: Dirk Schreckmann ]



Yes, i do need that class as it is part of my assignment at my
university. There is an assingment i have to do is Add.java and in it
actually java.text.DecimalFormat and cs1.Keyboard needs to be imported
before writing it. The description of this simple program is that it
prompts you twice to enter any number and gives you a total. Do you
think THIS class is downloadable from a website? if so could you suggest any?
 
Miric Ubaydov
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by somkiat puisungnoen:
How to compile cs1.Keyboard ?

Example on Windows OS.

source code in c:/src
class file in c:/classes

Code in c:/src/cs1/Keyboard.java

Compile cs1.Keyboard.java
1. cd c:/src/cs1
2. set p=c:/classes
3. set CLASSPATH=.;%p%;%CLASSPATH%
4. javac -d %p% Keyboard.java
5. Keyboard.class should be created in c:/classes/cs1 directory



i followed compiling 1, 2 but on third a message came out such as this:



Am i again missing something on this process?
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
on Unix/Linux OS MUST use

$CLASSPATH or $p replace %CLASSPATH% or %p%

and replace " ; " with " : "
 
Miric Ubaydov
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by somkiat puisungnoen:
on Unix/Linux OS MUST use

$CLASSPATH or $p replace %CLASSPATH% or %p%

and replace " ; " with " : "



it worked, thanks to you. but i apologize with another question, could you also tell me why it still says that the Keyboard class doens't exist when i complie the Lucky program? if this class needs to be located in java folder then i located it, however it's not doing the job.
 
Ranch Hand
Posts: 8946
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Put c:/classes/cs1 in classpath.
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

it worked, thanks to you. but i apologize with another question, could you also tell me why it still says that the Keyboard class doens't exist when i complie the Lucky program? if this class needs to be located in java folder then i located it, however it's not doing the job.



before compile Lucky.java , please check Keyboard.class in your clases directory.

For more information to solve problem, please post your step and message error.
 
Miric Ubaydov
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Couldn't open the jar launcher.

the error message:

"The jar file "Keyboard.class" couldn't be launched. Check the Console for possible error messages"

:roll:
 
Pradeep bhatt
Ranch Hand
Posts: 8946
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Miric Ubaydov:
Couldn't open the jar launcher.

the error message:

"The jar file "Keyboard.class" couldn't be launched. Check the Console for possible error messages"

:roll:



Jar file? From where is jar coming here? I hope that you are using java and not jar to execute java file.
 
Miric Ubaydov
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i'm using mac platform and i don't know why it launches with jar.
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First java with MAC
 
Miric Ubaydov
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If im not mssing anything else i have tried every option to compile a java program with cs1.Keyboard class. I copied this class into every java folders even into the directory where i saved the program.. alas NO success.

if anyone had this classpath problem before with Mac, i would appreiciate so much if you could share it here.

Miric
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic