FacebookTwitter
Hatrack River Forum   
my profile login | search | faq | forum home

  next oldest topic   next newest topic
» Hatrack River Forum » Active Forums » Books, Films, Food and Culture » Perl help [Now Java help, what a time to be alive] (Page 2)

  This topic comprises 2 pages: 1  2   
Author Topic: Perl help [Now Java help, what a time to be alive]
fugu13
Member
Member # 2859

 - posted      Profile for fugu13   Email fugu13         Edit/Delete Post 
http://www.omondo.com/faq/common/index.jsp

http://www.rgagnon.com/javadetails/java-0131.html

You should be able to make it use the arguments by just changing how windows runs the jar file, in the properties, I believe.

Posts: 15770 | Registered: Dec 2001  |  IP: Logged | Report this post to a Moderator
Hobbes
Member
Member # 433

 - posted      Profile for Hobbes   Email Hobbes         Edit/Delete Post 
OK, so I'm trying to create this jar file myself, I've put all my class into one directory, and I'm running the jar command on it. The command I run is this:

...jar cmvf add.txt Converter.jar Converter/*

add.txt contains this line (as a manifest file):
Main-Class: CFileProcessor.class

Converter.jar is the output jar file, and all the files are in Converter (the directory). The command runs, produces the jar file (and the verbose output tells me that all the required class files have been added). I then try to run the .jar file and it says it can not find the main class. Well the class is defaintly there (I've expanded it and checked, I've also tried labeling the path name as being outside and inside the directory Converter and checked spelling). When I expand the jar file the manifest file created does indded list the main class correctly, but that doesn't help the fact that it can't seem to find it. [Dont Know]

Hobbes [Smile]

Posts: 10602 | Registered: Oct 1999  |  IP: Logged | Report this post to a Moderator
Farmgirl
Member
Member # 5567

 - posted      Profile for Farmgirl   Email Farmgirl         Edit/Delete Post 
Remove the ".class" from the end of the class file, and then hit return (requires a new line)

Farmgirl (writing on behalf of my co-worker who knows this stuff)

Posts: 9538 | Registered: Aug 2003  |  IP: Logged | Report this post to a Moderator
Bokonon
Member
Member # 480

 - posted      Profile for Bokonon           Edit/Delete Post 
Yeah, to follow up FG, class files are generally not specified with their extension, while source files are, in Java.

Just a rule of thumb.

-Bok

Posts: 7021 | Registered: Nov 1999  |  IP: Logged | Report this post to a Moderator
Hobbes
Member
Member # 433

 - posted      Profile for Hobbes   Email Hobbes         Edit/Delete Post 
[Big Grin]

[Group Hug]

Thanks FarmWomen and co-worker. *Runs off to check*

[EDIT: and Bok [Smile] ]

Hobbes [Smile]

[ August 05, 2004, 04:09 PM: Message edited by: Hobbes ]

Posts: 10602 | Registered: Oct 1999  |  IP: Logged | Report this post to a Moderator
Farmgirl
Member
Member # 5567

 - posted      Profile for Farmgirl   Email Farmgirl         Edit/Delete Post 
[Angst] I've become plural now????

FG

Posts: 9538 | Registered: Aug 2003  |  IP: Logged | Report this post to a Moderator
Hobbes
Member
Member # 433

 - posted      Profile for Hobbes   Email Hobbes         Edit/Delete Post 
I have this problem, woman always becomes women when I type. I'm having it looked at. Or maybe it would be easier if you just went ahead and devloped multiple personalities...

By the way, it's still not working but I'm going to keep trying.

Hobbes [Smile]

Posts: 10602 | Registered: Oct 1999  |  IP: Logged | Report this post to a Moderator
Farmgirl
Member
Member # 5567

 - posted      Profile for Farmgirl   Email Farmgirl         Edit/Delete Post 
You put in the new line under the Main Class line? What error are you getting?

FG

Posts: 9538 | Registered: Aug 2003  |  IP: Logged | Report this post to a Moderator
Hobbes
Member
Member # 433

 - posted      Profile for Hobbes   Email Hobbes         Edit/Delete Post 
Yes I did, and the same error. I'm going to be more specific here.

In the base directory:
Converter (Folder)
Converter.jar (The jar file that's been created, and runs unsiccsefully)
add.txt (the data that's supposed to be added to the manifest file)

In Converter:
*.class (all the required class files, including the one with static void main (...) in it)
Various folders with other required files (my program has a dependency on another jar file called netcdf.jar, I've expanded it and put all the new files in this directory, with all of the class files)
.regconv (a file that my program requires, just some small ASCII data).

The exact line I'm using on Window's cmd:
D:\Hobbes\Java Source\Project 2>C:j2sdk1.4.2\bin\jar cmvf add.txt Converter.jar

This is followed by two possible options that I've tried:
Converter/
Converter/*
(and Converter alone as well)

add.txt has contained (always followed by a new line) the following lines (always it's only one line, but I've tried many options):
Main-Class: Converted/CFileProcessor
Main-Class: Converted\CFileProcessor
Main-Class: CFileProcessor

The error is:
Could not find the main class. Program will exit.

Hobbes [Smile]

Posts: 10602 | Registered: Oct 1999  |  IP: Logged | Report this post to a Moderator
Gregg
New Member
Member # 6752

 - posted      Profile for Gregg   Email Gregg         Edit/Delete Post 
Alrighty hobbes

If you place class files in folders and JAR those folders into the JAR file, your class file has to specify a package. Here is an example:

code:
package Converter;
public class hello
{
public static void main(String[] args)
{
System.out.println("Hello Hobbes");
}
}

Now, put that file in a folder call Converter and compile it.

Next, create a Manifest file like so:
code:
Main-Class: Converter/hello

And then do the JAR:

code:
C:\>"c:\Program Files\java\jdk1.5.0\bin\jar" -cmvf manifest.txt hello.jar Converter/*.class

HTH

P.S. I work with FarmGirl. [Smile]

Gregg Bolinger
Javaranch Sheriff | Weblog

[ August 05, 2004, 05:57 PM: Message edited by: Gregg ]

Posts: 2 | Registered: Aug 2004  |  IP: Logged | Report this post to a Moderator
kaioshin00
Member
Member # 3740

 - posted      Profile for kaioshin00   Email kaioshin00         Edit/Delete Post 
System.out.println("Java rules!");
Posts: 2756 | Registered: Jul 2002  |  IP: Logged | Report this post to a Moderator
Hobbes
Member
Member # 433

 - posted      Profile for Hobbes   Email Hobbes         Edit/Delete Post 
cout << "Java's lack of low-level control over the computer, and it's run-time compiling make it ideal for it's use as a multi-platform language, but when it comes down to power in a programming language nothing delivers that with felxibility and scalibilty like C++" << endl;

Hobbes [Smile]

Posts: 10602 | Registered: Oct 1999  |  IP: Logged | Report this post to a Moderator
Hobbes
Member
Member # 433

 - posted      Profile for Hobbes   Email Hobbes         Edit/Delete Post 
Big thanks to Gregg, I'll try that as soon as I get into work tomorrow. [Big Grin] [Group Hug]

Hobbes [Smile]

Posts: 10602 | Registered: Oct 1999  |  IP: Logged | Report this post to a Moderator
fugu13
Member
Member # 2859

 - posted      Profile for fugu13   Email fugu13         Edit/Delete Post 
Which is why Microsoft is moving to a very java-similar language, C#.

Plain and simple, if you want to develop high level software quickly, efficiently, and securely (in the general sense, there are always exceptions), you want a language less like C++ and more like Java (or even past Java for many purposes).

[ August 06, 2004, 12:27 AM: Message edited by: fugu13 ]

Posts: 15770 | Registered: Dec 2001  |  IP: Logged | Report this post to a Moderator
Hobbes
Member
Member # 433

 - posted      Profile for Hobbes   Email Hobbes         Edit/Delete Post 
Well I agree in general, but I don't think they have to take that route, through the use of standered libraries (like the STL) C++ can be turned into a high-level language just as easily as Java (in my opinion). I agree that if you're basically after quick programming and don't much care about speed a language like Java or C# will give you a much quicker return on your buck, but I'm of the opinion that taking the time to really develop standered libraries for C++ would allow people to use it as a high level language without giving up the functionality that accompanies a low-level language.

Now if you're after something as high level as say Perl, or PHP then C++ will be too far off the mark, but then again, so will Java.

Speaking of C#, has Microsoft finished writting their .NET platform for anything besides Windows? The last time I looked into this was years ago. [Embarrassed]

Hobbes [Smile]

Posts: 10602 | Registered: Oct 1999  |  IP: Logged | Report this post to a Moderator
fugu13
Member
Member # 2859

 - posted      Profile for fugu13   Email fugu13         Edit/Delete Post 
And unless you're using a JIT compiler (highly unlikely), there's no run time compiling in java . . . It uses java "machine" language bytecode instructions on the java virtual machine, just like you downloaded them off the internet or compiled them five minutes ago, no further compilation involved.
Posts: 15770 | Registered: Dec 2001  |  IP: Logged | Report this post to a Moderator
Hobbes
Member
Member # 433

 - posted      Profile for Hobbes   Email Hobbes         Edit/Delete Post 
You're right, compile is the wrong word, but I just strongly dislike the idea of having to run something on code that's already been compilied. [Dont Know]

Have you heard about the .NET?

Hobbes [Smile]

Posts: 10602 | Registered: Oct 1999  |  IP: Logged | Report this post to a Moderator
fugu13
Member
Member # 2859

 - posted      Profile for fugu13   Email fugu13         Edit/Delete Post 
Sorry Hobbes, but this one's one CS people have been looking at for a long time. Excepting speed, higher level languages have significant advantages over C++. Just the ability to dispense with the bookkeeping is a godsend, not to mention higher level abstractions. Average number of lines in a java project is something like half the lines in a C++ project doing the same thing, and that can be cut in half again or better by a higher level language. LOC improvements like that with better runtime security (from buffer overruns and such), better readability, and higher "paradigmicity" are very hard to argue with except when some overriding concern crops up.

Not only that, with many higher level languages you can write speed sensitive parts in C++ and still have most of the program in python or whatever.

And C# can run on pretty much any platform out there nowadays, even a lot of the winforms stuff. The server side stuff's been pretty much completely ported, in part by MS implementation (Rotor is their FreeBSD/OS X implementation, though its a little behind the times), and in part by open source projects (Mono and dotGNU, mainly the former).

Posts: 15770 | Registered: Dec 2001  |  IP: Logged | Report this post to a Moderator
fugu13
Member
Member # 2859

 - posted      Profile for fugu13   Email fugu13         Edit/Delete Post 
Hobbes, C++ code doesn't run on the metal exactly, either [Razz] . It has to go through the operating system for a lot of things (requesting memory, for instance [Smile] ).
Posts: 15770 | Registered: Dec 2001  |  IP: Logged | Report this post to a Moderator
Hobbes
Member
Member # 433

 - posted      Profile for Hobbes   Email Hobbes         Edit/Delete Post 
quote:
Sorry Hobbes, but this one's one CS people have been looking at for a long time. Excepting speed...
What are you sorry about? I prefer C++ for many reasons, one of which is that my mind works exactly like the way C++ is written (object oriented, but with no abstraction above hiding registry moves and the like). It's exactly as tedious as I like and incredibly powerful, and it is faster if you know what you're doing (which I do like to flatter myself that I do).

And I still think that if some real time and money was invested in good, high-level libraries C++ could really compete on that platform with languages like Java and C#, the reason it isn't competing is because no one wants to put in time and money. Which is acceptable, I wouldn't really want to use those libraries myself, and I wouldn't be surprised in the least if it wasn't really monetarily beneficial, I'm just saying if a company with some money really wanted to they could build C++ to compete on just about any level.

Hobbes [Smile]

Posts: 10602 | Registered: Oct 1999  |  IP: Logged | Report this post to a Moderator
Hobbes
Member
Member # 433

 - posted      Profile for Hobbes   Email Hobbes         Edit/Delete Post 
Fugu, going through the system for commands like file i/o and memory allocation is different then sotring all of it's commands in a byte format that can't directly run on the processor. [Razz] Java does all tha and has to be whatevered at run time.

Hobbes [Smile]

Posts: 10602 | Registered: Oct 1999  |  IP: Logged | Report this post to a Moderator
fugu13
Member
Member # 2859

 - posted      Profile for fugu13   Email fugu13         Edit/Delete Post 
Hobbes, more time has been invested in C++ than any other language, probably, and definitely in the past decade. I do assume you're using the Boost libraries, btw?

Yet even with all the time that's been invested in it, C++ still doesn't have nearly the development efficiency that higher level languages do.

And its not just calling some operating system functions, C++ has a (minimal) runtime environment. It does let the metal handle many of the calls, but its still very much there. Is Java significantly further from the metal? Sure, but C++ isn't right there on the metal.

Posts: 15770 | Registered: Dec 2001  |  IP: Logged | Report this post to a Moderator
fugu13
Member
Member # 2859

 - posted      Profile for fugu13   Email fugu13         Edit/Delete Post 
Actually, given the C++ was MS's big thing for at least a six or seven years but wasnt' able with their billions to mold it into what they needed for many purposes, I'm rather certain you're not quite correct with your assertion.
Posts: 15770 | Registered: Dec 2001  |  IP: Logged | Report this post to a Moderator
Hobbes
Member
Member # 433

 - posted      Profile for Hobbes   Email Hobbes         Edit/Delete Post 
[EDIT: Which assertion?]

I'm agreeing with on that Fugu, and I'm agreeing with you on the fact that turning it into a lnaguage that could high-level functionality is really just my own personal pipe-dream, I'm just saying it could be done. You're right though, I was reaching to far on that one.

Though I disagree that C++ is the most time-invested language, perhaps in the last century, but I'd be willing to bet dollars to donoughts (if I was willing to bet anything, which of course I'm not) that Fortran has a significantly larger amount of time invested in it.

What can I say, C++ will always be my favorite language, it's powerful, and for me it's not cluncky because I don't have to translate my thoughts to program in it, it's one of the reasons I so love programming. English is a language in which I speak like forienger, C++ is my native language of the mind. [Smile]

Hobbes [Smile]

[ August 06, 2004, 01:09 AM: Message edited by: Hobbes ]

Posts: 10602 | Registered: Oct 1999  |  IP: Logged | Report this post to a Moderator
fugu13
Member
Member # 2859

 - posted      Profile for fugu13   Email fugu13         Edit/Delete Post 
Fortran had more time spent programming in it, likely, but development on the language itself not so much as C++, I think.

Lisp is probably a better competitor, at least if you include the entire Lisp family, but possibly even just Common Lisp.

Posts: 15770 | Registered: Dec 2001  |  IP: Logged | Report this post to a Moderator
Hobbes
Member
Member # 433

 - posted      Profile for Hobbes   Email Hobbes         Edit/Delete Post 
I'm giving you the argument, I have no doubt that it's far more effective to program in Java for most companies (or C# or Lisp or some other at least kind of high-level language) especially with rapidly increasing processor speed (and most people using their 1.5GHZ to write letters and play solitare), the effeciency just isn't need like it's used to.

The one thing they did with Fortran was really write the compilies to the edge in efficiency, heck, until around 92 I believe it was, all C and C++ programs were first converted to Fortran and then compiled in Fortran because the compilers created faster code. High-level languages are going to give you a lot mroe devloping time though, since you have to write all those abstraction layers.

I think I'll go back to talking longingly of C++...or perhaps finishing the program I'm currently working on in C++. [Big Grin]

Hobbes [Smile]

Posts: 10602 | Registered: Oct 1999  |  IP: Logged | Report this post to a Moderator
fugu13
Member
Member # 2859

 - posted      Profile for fugu13   Email fugu13         Edit/Delete Post 
Nope [Smile] . C was C, and was compiled directly, first in a compiler written in assembly and then in a compiler written in C. You can read the abbreviated story in Kernighan and Ritchie, the standard book of C.

C++ was originally (when developed by our good friend Stroustrup) converted to C and then compiled (oddly enough, our other good friend SCO owns the rights to the descendants of this original compiler [Smile] ), but quickly became compiled directly.

I'm not sure what you mean about having to write all those abstraction layers . . . higher level languages are higher level because they make it easy to develop abstractions, and they cut down on development time, usually by large factors.

You might be interested in one of the few people out there I think is completely fluent in C++ : http://www.moderncppdesign.com/

Here's a few of his columns on the CUJ website:

[ April 13, 2019, 02:56 PM: Message edited by: Hatrack River ]

Posts: 15770 | Registered: Dec 2001  |  IP: Logged | Report this post to a Moderator
Hobbes
Member
Member # 433

 - posted      Profile for Hobbes   Email Hobbes         Edit/Delete Post 
I have this book with a title something akin to "Efficent C++ programming", and if I ever feel like everything that can be done has been done in terms of writting the most efficent code to do basic, everyday problems, I'll just read a few lines and remind myself that's just plain not true. [Smile]

quote:
I'm not sure what you mean about having to write all those abstraction layers . . . higher level languages are higher level because they make it easy to develop abstractions, and they cut down on development time, usually by large factors.
I mean that a high level language is one in which so much more code has to be written for the language itself, C++ has the abstraction that you don't have to worry about registry values and what not, but you have to deal with memory pretty directly (like arrays of charecters instead of String objects), every layer up you go in the language is a layer more you have to write into it. I was talking about the time making the language itself, not programming in it. [Smile]

Hobbes [Smile]

Posts: 10602 | Registered: Oct 1999  |  IP: Logged | Report this post to a Moderator
Hobbes
Member
Member # 433

 - posted      Profile for Hobbes   Email Hobbes         Edit/Delete Post 
It worked, thanks a lot everyone. [Big Grin]

Hobbes [Smile]

Posts: 10602 | Registered: Oct 1999  |  IP: Logged | Report this post to a Moderator
fugu13
Member
Member # 2859

 - posted      Profile for fugu13   Email fugu13         Edit/Delete Post 
Higher level language development isn't really all that hard, actually. Take a look at all the hobbyist-grown languages around, and you'll see that its pretty easy to develop a new language, particularly (say) a .NET CLR language.

And most of the development you're talking about in C++ is just writing those abstraction layers, anyways, because abstraction layers are what make programming more efficient, plain and simple [Smile] .

Posts: 15770 | Registered: Dec 2001  |  IP: Logged | Report this post to a Moderator
Hobbes
Member
Member # 433

 - posted      Profile for Hobbes   Email Hobbes         Edit/Delete Post 
If I was to explain how to run a .jar file on a Windows machine, and do so with a lot of of memory (like -Xmx512m type of memory) how would I do this? I would like to avoid using cmd if I can, though I wouldn't mind all that much making the user write a little batch file if I give them the skeleton (a one line batch file of course... well I guess it has to be two lines but not the point), but obviously I'd rather not do that. What's this you were talking about with properties for memory?

Hobbes [Smile]

Posts: 10602 | Registered: Oct 1999  |  IP: Logged | Report this post to a Moderator
fugu13
Member
Member # 2859

 - posted      Profile for fugu13   Email fugu13         Edit/Delete Post 
I was misremembering (or can't find what I was thinking of), the command is system wide (which we don't want)

http://forum.java.sun.com/thread.jsp?thread=517241&forum=22&message=2472461

So use that command in a batch file (with the memory expanding arg and the jar name filled in), and put the two in the same folder. Then name the batch file "Double Click to Launch AppName.bat" or something else really obvious.

Posts: 15770 | Registered: Dec 2001  |  IP: Logged | Report this post to a Moderator
Hobbes
Member
Member # 433

 - posted      Profile for Hobbes   Email Hobbes         Edit/Delete Post 
Here's what I wrote:

quote:

How to Run the Converter

The first step in running the file converter is unpacking it. In Linux or Unix you should be able to use the “unzip” command to do this. In Windows, right click on the file (Converter.zip) and then select “Extract All”.

No matter the operating system, you must have Java installed on your computer. You can download Java at Sun’s website. Once you’ve downloaded Java you have all the tools you need to run the file converter.

If you’re on Linux or Unix, then you can run the file converter with one line. Once you’re in the appropriate directory (within the Converter folder) the following line should run the program:

java -Xmx512m -jar Converter.jar

If you’re running Windows it is both easier and much more difficult. Double clicking on the file “Converter.jar” will run the program, but will do so with a very limited amount of memory. The file converter is very memory intensive, so it’s quite likely that it will hang if it runs this way. In the Windows version this program also comes with a MS-DOS batch file named “RunConverter.bat”. Double clicking this will run the program with the appropriate memory, if you installed Java in the default location, and if it’s the same release as was current when the converter was created. Failing that, try to find where your java files are (the normal is in C:\Program Files\Java\j2re1.4.2_04\bin\java, the "j2rel.1.4.2_04" will change when a new release of Java is made). Then open the batch file with a text editor like notepad or WordPad. The file should look like this:

“C:\Program Files\Java\j2re1.4.2_04\bin\java” -Xmx512m -jar Converter.jar

Change it so that it looks like this:

“Your_Java_Folder\bin\java” -Xmx512m -jar Converter.jar

Be sure to include the quotation marks and a new line at the end of the file. Save and exit, and then you should be able to run the file converter simply by double clicking the batch file.

How does that strike you?

Hobbes [Smile]

[ August 06, 2004, 10:54 AM: Message edited by: Hobbes ]

Posts: 10602 | Registered: Oct 1999  |  IP: Logged | Report this post to a Moderator
  This topic comprises 2 pages: 1  2   

   Close Topic   Feature Topic   Move Topic   Delete Topic next oldest topic   next newest topic
 - Printer-friendly view of this topic
Hop To:


Contact Us | Hatrack River Home Page

Copyright © 2008 Hatrack River Enterprises Inc. All rights reserved.
Reproduction in whole or in part without permission is prohibited.


Powered by Infopop Corporation
UBB.classic™ 6.7.2